class - c++ how to call function with subclass, having superclass pointer -
i have 3 classes, a, b , c: class { public: virtual bool sm(b b) = 0; virtual bool sm(c c) = 0; }; class b : public { bool sm(b b) { //code } bool sm(c c) { //code } }; class c : public { bool sm(b b) { //code } bool sm(c c) { //code } }; and vector<a*> objects , stores b or c objects. (for example generates randomly) can call somehow for(int = 0; < objects.size(); i++) { for(int j = i; j < objects.size(); j++) { objects[i].sm(objects[j]); } } without dynamic cast or something? because there can bit more of b-c classes , bag thing, , may there better way it? solution odelande said , understood, solution problem #include <iostream> #include <vector> class b; class c; class { public: virtual bool sm(a* a) = 0; virtual bool sm(b* b) = 0; virtual bool sm(c* c) = 0; }; class b : public { public: bool sm(a* a) { return a->sm(this); } bool sm(b* b) { std::cout &l