Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute Exam CPA-21-02 Topic 1 Question 13 Discussion

Actual exam question for C++ Institute's CPA-21-02 exam
Question #: 13
Topic #: 1
[All CPA-21-02 Questions]

What happens when you attempt to compile and run the following code?

#include

using namespace std;

class complex{

double re;

double im;

public:

complex() : re(0),im(0) {}

complex(double x) { re=x,im=x;};

complex(double x,double y) { re=x,im=y;}

void print() { cout << re << " " << im;}

};

int main(){

complex c1(1,2);

c1.print();

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

Hyman
2 days ago
But the constructor for c1 is (1,2), so it should print 1 2, right?
upvoted 0 times
...
Juliana
6 days ago
I disagree, I believe the answer is A) It prints: 0 0
upvoted 0 times
...
Hyman
7 days ago
I think the answer is B) It prints: 1 1
upvoted 0 times
...

Save Cancel