nouknouk
10th March 2006, 14:15
Hello,
I've got a comprehension problem of what happend in one of the project
i'm working on. It's (I think) a pure c++ problem...
Basically I've got a class gs_object than has got a VIRTUAL function
createList(). This createList() function is overloaded in another class
named ct_server that inherits gs_object.
in my code, it looks something like that :
class gs_object {
...
virtual void createList();
...
};
class ct_server : public gs_object {
...
virtual void createList();
void initInstance();
...
};
Here is the problem : in the function ct_server::initInstance, one boy of my team wanted to
call the gs_object::createList() base function, and not the overloaded
one (ct_server::createList() ). But, according to me he made a mistake
as he wrote :
(static_cast<GS_object*>(this))->createList();
instead of
gs_object::createList();
According to me, as createList() is virtual, this line of code should
call ct_server::createList and not gs_object::createList()
But it doesn't : when in run in debug mode, i can see it calls
gs_object::createList();
I can't understand why. Could you explain me ?
FYI, i'm using Visual C++ 7.1.3 ; Qt 3.3.4
I've got a comprehension problem of what happend in one of the project
i'm working on. It's (I think) a pure c++ problem...
Basically I've got a class gs_object than has got a VIRTUAL function
createList(). This createList() function is overloaded in another class
named ct_server that inherits gs_object.
in my code, it looks something like that :
class gs_object {
...
virtual void createList();
...
};
class ct_server : public gs_object {
...
virtual void createList();
void initInstance();
...
};
Here is the problem : in the function ct_server::initInstance, one boy of my team wanted to
call the gs_object::createList() base function, and not the overloaded
one (ct_server::createList() ). But, according to me he made a mistake
as he wrote :
(static_cast<GS_object*>(this))->createList();
instead of
gs_object::createList();
According to me, as createList() is virtual, this line of code should
call ct_server::createList and not gs_object::createList()
But it doesn't : when in run in debug mode, i can see it calls
gs_object::createList();
I can't understand why. Could you explain me ?
FYI, i'm using Visual C++ 7.1.3 ; Qt 3.3.4