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

Explain what is class definition in c++ ?

797


When do we use copy constructors?

779


How can you prevent accessing of the private parts of my class by other programmers (violating encapsulation)?

842


Why is polymorphism useful?

790


Is it possible to provide default values while overloading a binary operator?

994


Can user-defined object be declared as static data member of another class?

767


how to access grid view row?

1987


What is a character in c++?

762


What is the difference between an external iterator and an internal iterator?

847


Describe delete operator?

822


What does ios :: app do in c++?

770


Please explain class & object in c++?

772


Assume an array of structure is in order by studentID field of the record, where student IDs go from 101 to 500. Write the most efficient pseudocode algorithm you can to find the record with a specific studentID if every single student ID from 101 to 500 is used and the array has 400 elements. Write the most efficient pseudocode algorithm you can to find a record with a studentID near the end of the IDs, say in the range from 450 to 500, if not every single student ID in the range of 101 to 500 is used and the array size is only 300

1993


What is a .h file c++?

717


What is searching?

860