Hello guys. I have some doubts regarding class inheritance.
Code:
class A {
};
class B: public A {
};
So I made "vector<A*>" which contains objects from both class A and B, created as follows:
Code:
vector<A*> vec;
A* obj = new A(); A* obj = new B();
The main issue is I need to use a method which solely belongs to class B and apply it to "vec" elements.
The method is only to be applied on elements of the vector created by the following way: A* obj = new B(), which means that only B objects are subject to this method and therefore using shouldn't be illegal.
Is there any way I can solve the issue explained above? Thanks in advance.