[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

C++ Programming :: Objects and Classes - Discussion

Home > C++ Programming > Objects and Classes > MCQs Questions Discussion

52 / 41

Choose the correct option.

Which holds true for the following statement

class c: public A, public B

A2 member in class A, B should not have same name

B2 member in class A, C should not have same name

Cboth A & B

DNone of these

Answer: Option (Login/Signup)

Show Explanation

However we can have same names in multiple base classes. but we need to use scope resolution operator to access the specific data member of a class.

Like 

class A

{

   protected:

    int x;

};


class B

{

   protected:

    int x;

};

class Derived: public A, public B

{

    Derived()

    {

        A::x= 1;

        B::x= 2;

    }

};

Asked In :: Cisco

Post Your Answer Here:     

Reply    
Rate This: +0 -0
    Report


Report Error

Please Login First Click Here