Question
#include <iostream>
using namespace std;
class vec
{
public:
vec(float f1, float f2)
{
x = f1;
y = f2;
}
vec()
{
}
float x;
float y;
};
vec addvectors(vec v1, vec v2);
int main()
{
vec v1(3, 6);
vec v2(2, -2);
vec v3 = addvectors(v1, v2);
cout << v3.x << ", " << v3.y << endl;
}
vec addvectors(vec v1, vec v2)
{
vec result;
result.x = v1.x + v2.x;
result.y = v1.y + v2.y;
return result;
};
a.
4, 5
b.
4, 4
c.
5, 4
d.
5, 5
Posted under Object Oriented Programming Using C++
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What is the output of this program?
Similar Questions
Discover Related MCQs
Q. What will be the type of output of vector cross product?
View solution
Q. Which function is used to optimize the space in vector?
View solution
Q. What is the use of vector arithmetic in c++?
View solution
Q. Which header file is used to operate on numeric sequences?
View solution
Q. Which mathematics library is used for vector manipulation in c++?
View solution
Q. What is the use of accumulate function in numeric library?
View solution
Q. How many parameters are available in partial_sum function in c++?
View solution
Q. What is the default operation of adjacent_difference function in numeric library?
View solution
Q. Which header file is used to create the pseudo random generator?
View solution
Q. Which is a constant defined in <cstdlib> header file?
View solution
Q. How many parameters are available in srand function?
View solution
Q. Which operator is used to produce a certain number in a specific range?
View solution
Q. Which can be used to create a random number without duplication?
View solution
Q. Ios: : skipws, ios: : left, ios: : dec, ios: : fixed, is an example of
View solution
Q. If we don't want any ios object can be declared in ios class, we can use a default constructor
View solution
Q. C++ uses directive because
View solution
Q. The unformatted input functions are handled by
View solution
Q. The istream class defines the
View solution
Q. Which from the following functions does not extract the delimiter character from the input stream?
View solution
Q. Iostream is a subclass of
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Object Oriented Programming Using C++? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!