Friday, 23 April 2021

Scope Resolution Operator in C++ Qus: 2

 #include<iostream.h>

#include<conio.h>

class A

{

public:

int x;

A()

{

x=10;

}

};

class B

{

public:

int x;

B()

{

x=5;

}

};

class C:A,B

{

public:

C()

{

//cout<<x<<endl;         //Ambigous

cout<<A::x<<endl;

cout<<B::x<<endl;

}

};

int main()

{

clrscr();

C ob;

getch();

return 0;

}

No comments:

Post a Comment