C++ overridden function not called
I am running into an issue where an overloaded function is not called, and the base function is called instead. I suspect this is related to how things are split between the project files. In files obj1.h/obj1.cpp I have something like this class obj1{ public: void print(); }; void obj1::print(){ cout << "obj1::print()"; } In files obj2.h/obj2.cpp I have something like this: #include "obj1.h" class obj2 : public obj1{ public: void print(); }; void obj2::print(){ cout << "obj2::print()"; } In separate files, I do something like this: #include "obj1.h" class obj3{ public: vector<obj1*> objlist;