Question
C++ PLEASE I NEED HELP IN THIS QUESTION Complete the skeleton of the following class: class B { int a, b, c; public: B( )
C++
PLEASE I NEED HELP IN THIS QUESTION
Complete the skeleton of the following class:
class B
{
int a, b, c;
public:
B( ) {.} // set a = 0, b=0, c=0
B(int x, int y, int z) { } // set a=x, b=y, c=z
B(const A & x) { }; // copy constructor
B & operator = (A & x) { }; // overloading = operator
print( ) { // print out the values of a, b, c }
};
Write a main routine in which you have the following statements:
int main( )
{
// statement 1
B x;
// print out the content of x
// statement 2
B y(2, 3, 4);
// print out the content of y
// statement 3
B z(y);
// print out the content of z
// statement 4
B w = z;
// print out the content of w
// statement 5
B v;
// print out the content of v
// statement 6
v = w;
// print out the content of v
return 0;
}
Explain which member function of class B is called for each of the above 6 statements. Write some statements to print out the values of data members of objects x, y, z, w, and v. You may need to present the results via a screenshot.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started