Hello again.
I've been working with a somewhat complex class heirarchy and have run into a problem. More than likely it stems from not fully understanding how C++ derived classes inherit from base classes.
To keep things simple, I have the following three classes defined as such:
The weird thing that's happening is that when I call the overloaded function from FooBar myFunc() from a list of Foo's (e.g., std::vector<Foo*>), the correct function is called. But myFunc2() calls the function from Foo, not from Bar or FooBar.Code:class Foo { private: virtual void myFunc() { printf("Hello!"); } virtual void myFunc2() { printf("'ello!"); } }; class Bar : public Foo { private: void myFunc() { printf("Hello 2!"); } void myFunc2() { printf("'ello 2!"); } }; class FooBar : public Bar { private: void myFunc() { printf("Hello 3!"); } void myFunc2() { printf("'ello 3!"); } };
I'm not sure this is clear enough but I'm hoping I provided enough information and that my problem is something really simple or that I just overlooked something.
Thanks!



LinkBack URL
About LinkBacks





Thanks again!