Change
((ITCPServer *)&run)->Bind();
to
(dynamic_cast<ITCPServer*>(run))->Bind();
Reasons:
1. Don't use C-style typecasts in C++ programs, they may not do what you expect them to, especially when dealing with classes that have virtual methods!
dynamic_cast
and the other specialized forms of casting available in C++ will not only be more verbose on your intentions on performing the casting, and will do automatic sanity checks at both compile-time and run-time!
2. You applied the type cast to the address of
run
, which already is a pointer. So the pointer
run
was interpreted as a class instance, which makes no sense at all! Note that if you had used
dynamic_cast
to start with, the compiler would have pointed out your error...
[edit] fixed cast type from
itcpserver
to
ITCPServer*
[/edit]