Tuesday, August 31, 2004

Some more useful stuff on C++

Regarding the typecasting possibilities in C++, here is a good article to read:
http://cplusplus.com/doc/tutorial/tut5-4.html

My supervisor informed me of this tool called Doxygen for documenting C++/Java/Perl/XML code. I suppose most C++ geeks know it already. I am playing with it for sometime. The URL for the doxygen website: http://www.doxygen.org/





Monday, August 16, 2004

Why C/C++ is intriguing?

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 :)


Tuesday, August 10, 2004

Another C++ Questionnaire!

Some more standard c++ interview questions I have encountered?

1) What are the disadvantages of a default copy constructor( He reached this question after asking me what is a copy constructor? how it works? what happens if its missing?)

2) What is the difference between pointer and a reference? What are the pros and cons of pointers versus references?

P.S: For all C++ geeks who want to know what is the exact difference between a pointer and a reference...read this article:
http://rafb.net/efnet_cpp/faq/concepts/ptrref/

3) What is virtual inheritance? Why is it useful?

4) What is a friend function? Why is it used? Why is it often used for operator overloading?

5) What is the difference between copy constructor and an assignment operator?

6) What is the difference between typecasting in C and C++?

7) What is the use of inline functions in programs?

8) What is a virtual function? What is a pure virtual function? What is an abstract base class? (As usual he asked me to provide examples for these)

I have been interviewing lately and i realise that the more i know, the more confused i get !! :)

I am getting insight also into how C++ compiler works in different situations!