Skip to main content
gamedev.net
🔒 Locked

Virtual Declaration

Started by phyl0men0 1 reply 750+ views
Original Post
phyl0men0
phyl0men0
Hi all I have 2 projects, an executable and a DLL. Executable: In this project I have a class called classA, which is declared in a normal header file. There are a few member functions. The definitions of this functions are in a normal cpp file. DLL This DLL only includes the header file of classA(from the executable). The DLL receives an pointer to an classA and tries to call a member function of classA. When I try to compile I receive a linker error "unresolved symbols...". But when I declare all the functions in the classA as virtual all works fine. Can somebody explain that to me? thx phyl0men0
ga
ga
in the dll, the addresses of the member functions are unknown so it can''t call them; if the function is virtual, the class instance to which you get a pointer in the dll has got a vtable (or a pointer to a vtable), in the vtable the addresses of the virtual functions are stored, so the virtual functions can be called without knowing the addresses of their implementations.
Visit our homepage: www.rarebyte.de.stGA
phyl0men0
phyl0men0
thx for your reply!!

greetz phyl0men0

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.