Click here to Skip to main content
15,881,709 members
Articles / Programming Languages / C++

Virtual table creation

Rate me:
Please Sign up or sign in to vote.
4.50/5 (2 votes)
25 Dec 2012CPOL 0  
Such a simple question, but I knew even pretty experienced developers who have been confused.The answer depends on what you call a "virtual table". It does exist as the image in the object file, and later it comes to the executable file and finally loaded to the memory. In all stages, it is...

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
25 Dec 2012sourabhmehta 3 alternatives  
Hi All,I know there are so many existing forums on the same topic. But they are not clear.so my question is..When is the virtual table created in c++ whether compile-time or run-time?In few of the forums it is mentioned that,at compile time only the layout of the table gets created...
Please Sign up or sign in to vote.
25 Dec 2012«_Superman_»
This article talks about virtual tables - Polymorphism in C[^]
Please Sign up or sign in to vote.
25 Dec 2012nv3
The compiler already needs to know which function's address is in cell number n of the v-table of a class. Otherwise it couldn't generate code to call that function. So basically the answer to your question is: V-tables are prepared at compile time. So the compiler for instance knows that...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
United States United States
Physics, physical and quantum optics, mathematics, computer science, control systems for manufacturing, diagnostics, testing, and research, theory of music, musical instruments… Contact me: https://www.SAKryukov.org

Comments and Discussions