So object slicing is when you do copy by value and its completely lost, but when I do polymorphism with pointers and references, the extra parts are also technically lost until I cast the pointer. So if I have Base-> Derived-> Derived2, and I store a pointer to a Derived2 object into an object that holds a pointer to Derived, then I would only be able to access Base and derived members and functions and virtual functions of Derived2 correct? The only way i would be able to access derived2 members and functions would be to cast it?
class Base{
public:
int x;
int y;
void someFunc.....;
virtual void vFunc....;
}
class Derived: public Base{
public:
int z;
int s;
void someFunc2....;
}
class Derived2: public Derived{
public:
int o;
void vFunc......;
}
int main(){
Derived* ptr = new Derived2();
}
I wouldnt be able to do ptr->o; but i can access everything else? from base to derived and including derived2 virtual functions