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 :

Qt Code:
  1. class gs_object {
  2. ...
  3. virtual void createList();
  4. ...
  5. };
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. class ct_server : public gs_object {
  2. ...
  3. virtual void createList();
  4. void initInstance();
  5. ...
  6. };
To copy to clipboard, switch view to plain text mode 

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