here it is the ripped source code
//res_mgr.h
template<class T>
class res_mgr
{
public:
res_mgr(){ printf("allocated"); }
virtual ~res_mgr(){ printf("deleted"); }
void add(const std::string& name){ printf("added %s\n", name.c_str()); }
};
//font_mgr.h
class font_mgr : public res_mgr<font> //font is ok, no need to check its implementation
{
public:
font_mgr()
:res_mgr<font>()
{
}
~font_mgr()
{
}
void add(const std::string& name){ printf("font added [%s]\n", name.c_str()); } //this function never gets called!! I wonder why
};
for example, I create a font_mgr
font_mgr *mgr = new font_mgr;
when I call
mgr->add("blah blah");
the function that gets called is always the res_mgr::add(). I want it to call font_mgr::add() instead. btw I haven't slept for 8 hours now and I'm confused. Puh lease help this poor fellow