Click here to Skip to main content
16,006,006 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to get the application's full path and file name at run time? Pin
BadJerry23-Feb-05 2:31
BadJerry23-Feb-05 2:31 
AnswerRe: How to get the application's full path and file name at run time? Pin
James R. Twine23-Feb-05 2:38
James R. Twine23-Feb-05 2:38 
GeneralProblem with CGridCtrl with combo box Pin
Bob Stanneveld23-Feb-05 1:55
Bob Stanneveld23-Feb-05 1:55 
GeneralHelp needed! Pin
Member 25547123-Feb-05 1:44
Member 25547123-Feb-05 1:44 
GeneralRe: Help needed! Pin
David Crow23-Feb-05 2:31
David Crow23-Feb-05 2:31 
GeneralRe: Help needed! Pin
Steen Krogsgaard23-Feb-05 2:42
Steen Krogsgaard23-Feb-05 2:42 
GeneralRe: Help needed! Pin
Steen Krogsgaard23-Feb-05 2:32
Steen Krogsgaard23-Feb-05 2:32 
GeneralRe: Help needed! Pin
Ryan Binns23-Feb-05 17:11
Ryan Binns23-Feb-05 17:11 
Steen Krogsgaard wrote:
I'm not sure, but since it's function pointers it makes most sense to me that it is in the code segment. Its definitely not in stack or heap. The vtable is created at compile time, as there is only one vtable per class, and this vtable is shared by all instances of that class

Don't take it personally, but that's not quite right Smile | :)

The vtable is part of an object - each object has its own copy. It is stored as part of the object's data, and is initialised as part of the object's construction, before the constructor is called (disassemble the constructor code to see where). It's initialised by copying the data verbatim from its class's class-specific vtable.

The reason it's got its own copy is so that virtual functions work. Take the following code:
void myFunc(MyBaseObject* objPtr)
{
   objPtr->myVirtualFunction();
}<br/><br/>myFunc(new MyDerivedObject);
If the vtable was per class, then this wouldn't work. When myVirtualFunction was invoked, the compiler would have to know what type of object objPtr was so it could invoke the correct implementation of the function. Since the whole point of polymorphism is that compiler doesn't have to know what type of object it's got, this simply will not work. If the vtable is per-object, all the compiler has to do is lookup in the object's vtable the function pointer using the correct table index and call it. The compiler has to make sure that each implementation of a virtual function is given the same index into the table for all the classes derived from the same base class. So in essence, this call translates to something like:
(*objPtr->vtable[myVirtualFunctionVTABLEindex])()
Hopefully that clears things up a little Smile | :)

Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

GeneralRe: Help needed! Pin
Steen Krogsgaard23-Feb-05 21:46
Steen Krogsgaard23-Feb-05 21:46 
GeneralRe: Help needed! Pin
Ryan Binns24-Feb-05 12:38
Ryan Binns24-Feb-05 12:38 
GeneralRe: Help needed! Pin
Steen Krogsgaard24-Feb-05 22:18
Steen Krogsgaard24-Feb-05 22:18 
GeneralRe: Help needed! Pin
Ryan Binns25-Feb-05 1:06
Ryan Binns25-Feb-05 1:06 
GeneralHandling messages in another class Pin
tttyip23-Feb-05 0:25
tttyip23-Feb-05 0:25 
GeneralRe: Handling messages in another class Pin
RChin23-Feb-05 0:51
RChin23-Feb-05 0:51 
Generalmerge some cells from the same row in CListCtrl Pin
catalin buj23-Feb-05 0:14
catalin buj23-Feb-05 0:14 
GeneralRe: merge some cells from the same row in CListCtrl Pin
bitpusher23-Feb-05 9:56
bitpusher23-Feb-05 9:56 
GeneralRe: merge some cells from the same row in CListCtrl Pin
catalin buj23-Feb-05 22:19
catalin buj23-Feb-05 22:19 
GeneralProblem with metafile-playback in print preview Pin
Christian Waluga22-Feb-05 23:35
Christian Waluga22-Feb-05 23:35 
GeneralRe: Problem with metafile-playback in print preview Pin
Christian Waluga23-Feb-05 22:15
Christian Waluga23-Feb-05 22:15 
GeneralUse C++ written class in VB Pin
Logan from Singapore22-Feb-05 23:33
Logan from Singapore22-Feb-05 23:33 
GeneralRe: Use C++ written class in VB Pin
ThatsAlok22-Feb-05 23:52
ThatsAlok22-Feb-05 23:52 
Generalappend CString [] Pin
kittunair22-Feb-05 23:28
kittunair22-Feb-05 23:28 
GeneralRe: append CString [] Pin
ThatsAlok22-Feb-05 23:50
ThatsAlok22-Feb-05 23:50 
GeneralRe: append CString [] Pin
David Nash23-Feb-05 7:03
David Nash23-Feb-05 7:03 
GeneralDate Validation Pin
Renjith Ramachandran22-Feb-05 23:16
Renjith Ramachandran22-Feb-05 23:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.