What are Virtual Functions? How to implement virtual
functions in "C" ?

Answer Posted / jaroosh

To address the second part of the question - the only way to
implement mechanism like virtual functions in C is by using
function pointers, creating structure emulating Virtual
Pointer Table etc.
Implementation is rather complicated and creates a lot of
overhead for every structure that we want to use with
virtual functions (since ANSI C doesnt support inheritance
and polimorphism, it also calls for emulating this behavior,
so virtual functions for C is actually more of a form of art
than anything usefull).

Is This Answer Correct ?    7 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a .lib file in c++?

645


What is data abstraction? How is it different from data encapsulation?

617


What is ctime c++?

685


What is constant in c++ with example?

722


Is map ordered c++?

688






What is set in c++?

745


Explain the auto storage classes in c++.

707


If all is successful, what should main return a) 0 b) 1 c) void

657


How the keyword struct is different from the keyword class in c++?

678


Which bit wise operator is suitable for turning off a particular bit in a number?

737


What is the c++ code?

643


Differentiate between a template class and class template in c++?

718


How much maximum can you allocate in a single call to malloc()?

723


What are the syntactic rules to be avoid ambiguity in multiple inheritance?

758


What is the operator in c++?

719