1. Assume the following: class Complex { public: Complex(int, int); //initializes the private data members to the passed in values: // real = value of the first argument // imag = value of the second argument Complex add( Complex ); //returns a Complex object that holds the sum of two //Complex objects void print(); //prints the values of the private data members in the format: // (real, imag) private: int real, imag; }; Will these two lines work below in a driver program for the class? Complex c1(40,50); //create object (line 1) c1.real=55; //move in value of 55 (line 2) a. yes it will work fine b. no, you will get a compiler error c. need more information on the object d. line 1 will cause an error line 2 will work fine
1.
Assume the following:
class Complex
{
public:
Complex(int, int); //initializes the private data members to the passed in values:
// real = value of the first argument
// imag = value of the second argument
Complex add( Complex ); //returns a Complex object that holds the sum of two
//Complex objects
void print(); //prints the values of the private data members in the format:
// (real, imag)
private:
int real, imag;
};
Will these two lines work below in a driver program for the class?
Complex c1(40,50); //create object (line 1)
c1.real=55; //move in value of 55 (line 2)
a. |
yes it will work fine |
|
b. |
no, you will get a compiler error |
|
c. |
need more information on the object |
|
d. |
line 1 will cause an error line 2 will work fine |
Trending now
This is a popular solution!
Step by step
Solved in 2 steps