Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the definition of the following class: class CC { public: CC(); //Line

ID: 3642905 • Letter: C

Question

Consider the definition of the following class:
class CC
{
public:
CC(); //Line 1
CC(int); //Line 2
CC(int, int) //Line 3
CC(double, int) //Line 4
private:
int u;
double v;
};
a. Give the line numbers containing the constructors that is executed in each of the following declarations:
i. CC one;
ii. CC two(5, 6);
iii. CC three(3.5, 8);
b. What is the definition of the constructor in Line 1 so that the private data members are initialized to 0.
c. What is the definition of the constructor in Line 2 so that the private data member u is initialized according to the value of the parameter, and the private data member v is initialized to 0.

Explanation / Answer

a). i) Line 1 ii) Line 3 iii) Line 4 b) CC(): u(0), v(0) {} c) CC(int n): u(n), v(0) {}