c++ - Passing inherited class type as argument -
Problems passing through the type of class inherited in the form of logic for the method that takes me to class squared has occurred. class base {...} Category derivative: public base {...} square container {vector & lt; Base * & gt; remaining part; // 1 public: zero addToCont (base x) {// 2 cont.push_back (& amp; x); }} Int main () {Container C; c.addToCont (Derivative (P1, P2)); // 3} 1) I think I need the containers of points for objects to work 2) Error in conversion from derivative to base 3) I do not want to change this call. I tried derived D (P1, P2); C.addToCont (d); with addToCont (base and x) and it worked for me. My problem is that I have 3 derivative classes and I do not want to overload the add method 3 times. I think I have to add some virtual pattern or some type of structure to those classes, but I did not find anything about it I'm a newbie in heritage and I am very confused about this. Thank you for all of your help. ...