Advertisement Remove all ads

Observe the Following C++ Code and Answer the Questions (I) and (Ii). Note: Assume All Necessary Files Are Included. Which Objected Programming Features is Illustrated by the Definition of Classes First and Second? and Write Statement 1 and Statement 2 to Execute Member Function 1 and Member Function 2 Respectively Using the Object S - Computer Science (C++)

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?
Advertisement Remove all ads
Advertisement Remove all ads
Advertisement Remove all ads
Share
Notifications

View all notifications


      Forgot password?
View in app×