Ok so i'm trying a few things with inheritance, heres the code:
class A {
protected:
int i;
public:
A() :i(0) {}
A(int n):i(n) {}
};
class B :public A {
public:
B() :A() { }
B(int n):A(n) { }
};
I know that you can affect a pointer to parent with a pointer to child, and i understand why:
B* b = new B();
A *a(0);
a = b;
But i also found out that you can do this:
A ac = *b;
or
A &ac = *b;
But isnt it literally affecting the object b to ac, instead of just pointer to memory location?
By the way, i'm not completely sure of what using & does in a declaration, I understand it as a default pass by reference.