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 nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
- PLZ help wiith the following: IN JAVA If an inner class contains non static members, then the class name must be modified by the keyword: Final Static Void Protectedarrow_forwardWhat are the three tasks you must do for classes that include member variables that are pointers?arrow_forwardSolve the questionarrow_forward
- Q2: Write a c++ program that implements the following UML diagram including functions and constructors' definitions. In addition to the user program code that declares object for each class and show how the derived class object uses the base class members. OOPCourse Student ID: int Grades[5]: int + setgrades(int arr[], int ): void + setID(int): int + setage(int): double + print():void + age:int + OOPstudent() OOPCourse OOPLAB OOPLab Reports[4]: int + setmarks(int arr[), int ): void + print():void + OOPLab()arrow_forwardc++ programmingarrow_forwardGiven the code: class Book { public: string title; string author; }; Write an internal function definition for a mutator function for this class.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education