#include<iostream>
using namespace std;
class uvw;
class abc{
private:
int privateMember;
protected:
int protMember;
public:
int publicMember;
};
class def : private abc{
public:
void dummy_fn();
};
class uvw: public def{
};
void def::dummy_fn()
{
abc x;
def y;
uvw z;
cout << z.protMember << endl; // This can be accessed and doesn't give a compile-error
}
From what I understand, after def
inherits privately from abc
, protMember
and publicMember
become private in def
. So, now when uvw
inherits from def
, it shouldn't have any data members. But we can weirdly access z.protMember
from dummy_fn()
, where as z
shouldn't have a variable protMember
in the first place. Am I going wrong anywhere?