C++ language (Composition problem) Given the following two classes A and B, where all member functions have been fully implemented inline. class A { public: void f(int arg) { data = arg; } int g() { return data; } private: int data; }; class B { public: A x; }; int main() { B obj; // ... write code here return 0; } a. Insert the code in the main() function that assigns integer value 99 to the “data” member of obj, which is a B class object). b.Write the code to display the value (i.e., 99) that has just been assigned to the obj. c. Note that only a single object obj of B class is declared. How many times are constructors called? If more than one constructor is called, in what order are they called?
C++ language (Composition problem)
Given the following two classes A and B, where all member functions have been fully implemented inline.
class A { public: void f(int arg) { data = arg; } int g() { return data; } private: int data; }; class B { public: A x; }; int main() { B obj; // ... write code here return 0; }
a. Insert the code in the main() function that assigns integer value 99 to the “data” member of obj, which is a B class object).
b.Write the code to display the value (i.e., 99) that has just been assigned to the obj.
c. Note that only a single object obj of B class is declared. How many times are constructors called? If more than one constructor is called, in what order are they called?
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images