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

plese help me with this this is due in 1 hour: Consider the following class defi

ID: 3685178 • Letter: P

Question

plese help me with this this is due in 1 hour:

Consider the following class definitions:
class Base1{
public:
void Base2();
private:
void Base3();
double baseVal;
};
class Derive : public Base1{
public:
void drive1();
void drive2();
private:
int driveVal;
};
a. List all private data members.
b. List all data members that the class Derive’s member functions can reference.
c. List all functions that an object created from class Base1 can invoke.
d. List all functions that an object created from class Derive can invoke.

Explanation / Answer

a. List all private data members.

Ans: baseVal

        driveVal are the private data members.

b. List all data members that the class Derive’s member functions can reference.

Ans: baseVal

        driveVal

The class Derive’s member functions can refer to the data member’s baseVal and driveVal. Althought both baseVal and driveVal are private, since the Derive class inherits Base1 it can access the members of Base1 either they are public or private.


c. List all functions that an object created from class Base1 can invoke.

Ans: void Base2()

        void Base3()

An object of Base1 can invoke only its own member functions i.e., Base2() and Base3(). It cannot access any of the data members or member functions of the Derive class.


d. List all functions that an object created from class Derive can invoke.

Ans: The Derive class can access all the data members and member function of both the Base1 class and Derive class.

Hence the functions that an object created from class Derive can invoke

Base2()

Base3()

drive1()

drive2()