My questions is why b.getmultiply();
will not cause compilation error?
Class B
is private inherit from class A
, and x
and y
are members of class A
.
class A {
public:
int x;
int y;
void set(int a, int b) { x = a; y =b;}
};
class B : private A{
public:
int getmultiply (void){
return x*y;}
};
int main(void)
{
B b;
//b.set(3,4); // this will cause compilation error
cout << b.getmultiply(); // why this will not??
return 0;
}