Some more questions to ponder about:
1) How would you implement virtual functions in C?
Solution: Since C provides function pointers, we can use this to emulate virtual functions and the pointer to the virtual function table.
Here is an interesting tutorial on function pointers and callbacks:
http://www.function-pointer.org/zip/e_fpt.pdf
One more interesting thing to think about is how the typecasting in C is different from typecasting in C++?
As far as I know C++ provides typecasting in 2 possibilities in syntax:
result=(float)answer;
result=float(answer);
i dont know about the compiler internals of how typecasting is handled in C++! I will find out and post it here if i find something useful.
I am planning to write a tutorial on virtual functions, the table etc. hopefully i can post it here soon :)
No comments:
Post a Comment