The C++ language provides virtual functions. Within the constraints of a pure C language implementation, how can a similar effect be achieved?
The C++ language provides virtual functions. Within the constraints of a pure C language
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Stolen from here.
From the C++ class
a C code fragment can be derived. The three C++ member functions of
class Aare rewritten using out-of-line (standalone) code and collected by address into a struct namedA_functable. The data members ofAand combined with the function table into a C struct namedA.More elaborate than necessary, but it gets the point across.