A little question about classes
Hey guys! As I'm slowly learning C++, some questions arise and I think that this is the perfect place to ask them. Let's say we have a base class "A" and a derived class "B". To dynamically allocate object of class B we could write thisHowever, I often seen that some people write this So, my question is: Why would you do this? If you create an object of Derived Class with a pointer to a Base Class, then you can only access the derived members of that class, losing access to the rest of the class members. What is the reason for choosing second method over first method? Thank you in advance.