Can you explain why this is not allowed,
#include <stdio.h>
class B {
private:
int a;
public:
int a;
};
int main() {
return 0;
}
while this is?
#include <stdio.h>
class A {
public:
int a;
};
class B : public A{
private:
int a;
};
int main() {
return 0;
}
In both the cases, we have one public and one private variable named a in class B.
edited now!
No, thats not true.
In the first case, you can’t have two identifiers with the same name in the same scope. While in the second case,
B::ahidesA::a, and to accessA::ayou have to fully qualify the name: