Assume the following:
class A {
public:
A();
protected:
int a;
};
class B : public A {
public:
B();
};
My questions:
- Can I access (directly) the protected data members of A and maybe modify them without having to use public member functions?
- Can I treat A inside B as an "existing" object so that I can return A by reference and be able to modify its data member?
I am new to C++. I tried couple things to treat "A" as an object but I keep getting error messages. Here is one thing I have tried:
A & B::getA() {
return A; //error: "A does not refer to a value"
}