Observe the following C++ code and answer the questions (i) and (ii).
Note: Assume all necessary files are included.
class FIRST
{
int Numl;
public:
void Display()
{
cout<<Numl<<endl; //Member Function 1
}
};
class SECOND: public FIRST
{
int Num2;
public:
void Display() //Member Function 2
{
cout<<Num2<<endl;
}
};
Void main()
{
SECOND S;
___________ // Statement 1
___________ // Statement 2
}
1) Which Objected Programming features is illustrated by the definition of classes FIRST and SECOND?
2) Write Statement 1 and Statement 2 to execute Member Function 1 and Member Function 2 respectively using the object S
Advertisement Remove all ads
Solution
1) Single Inheritance
2) S.display ();
S.First :: display ();
Concept: Member of a Class - Data Members and Member Functions (Methods)
Is there an error in this question or solution?
APPEARS IN
Advertisement Remove all ads