C++ Typing and OOP child classes
- by Zack
I'm a bit confused:
If I have a base class A, and a class B which extends A, can a variable of the type A hold a value of the type B and vice versa?
If yes, why? Aren't they completely different even if B is derived from A? How about type-safety?
If this is possible, what things do I have to mind when taking use of this? How would this work out in terms of performance?
Note: Sorry if I asked too many questions, just ignore them and just look out for those "marked" with the list decoration dot :)
Also, this is not my homework. I'm a hobby programmer and have skills in scripting languages with OOP, yet I'm relatively new to OOP typing in C++.