Wednesday, January 16, 2008

Some more Interview Qns

Useful Links
http://diamond/exchweb/bin/redir.asp?URL=http://www.gnu.org/software/libc/manual/html_node/index.html
http://diamond/exchweb/bin/redir.asp?URL=http://www.parashift.com/c%2B%2B-faq-lite/

1. What is logical difference between Memory leak & dangling pointer?
A dangling pointer occurs when a pointer doesnot have a target. Example includes an uninitialized pointer and a pointer whose target has been deallocated(perhaps via an aliasing pointer).
A memory leak occurs when a process fails to deallocate memory and does not retain any pointer to that memory. The result is that the process can make no use of memory, nor can it deallocate the memory.
2. How to allocate dynamic memory on stack?
http://diamond/exchweb/bin/redir.asp?URL=http://www.codersource.net/c%2B%2B_dynamic_memory_allocation.aspx
3. What is Template?
http://diamond/exchweb/bin/redir.asp?URL=http://www.cplusplus.com/doc/tutorial/templates.html
http://diamond/exchweb/bin/redir.asp?URL=http://www.codersource.net/cpp_class_templates.html
4. What is STL? Explain different containers. Introduction & Overview:
http://diamond/exchweb/bin/redir.asp?URL=http://www.codebeach.com/tutorials/what-is-stl.asp
Everything about STL:
http://diamond/exchweb/bin/redir.asp?URL=http://www.decompile.com/html/tut.html
5. What are smart pointers. Explain in detail.
http://diamond/exchweb/bin/redir.asp?URL=http://en.wikipedia.org/wiki/Smart_pointer http://diamond/exchweb/bin/redir.asp?URL=http://www.informit.com/articles/article.aspx?p=31529
6. Explain exception handling.
http://diamond/exchweb/bin/redir.asp?URL=http://en.wikipedia.org/wiki/Exception_handling
http://diamond/exchweb/bin/redir.asp?URL=http://www.eastcoastgames.com/articles/cppexception.html
7. What is casting?
http://diamond/exchweb/bin/redir.asp?URL=http://www.codeguru.com/forum/showthread.php?t=312456
http://diamond/exchweb/bin/redir.asp?URL=http://www.acm.org/crossroads/xrds3-1/ovp3-1.html
8. Difference between new operator and operator new. When do we use operator new?
Here is what I meant.
------ 1 ------ Foo* p = static_cast(operator new (n * sizeof (Foo))); // Stuff delete p; ---------------
------ 2 ------ Foo* p = new Foo [n]; // Stuff delete[] p; The former will allocate with the global operator new allocator, enough room for n Foo objects, but will not call any constructor. So, p will point to raw memory, and accessing any member of Foo, or casting Foo to one of its base class, or doing similar things, will have undefined behaviour (see [basic.life]-5) Moreover, the delete expression will call a destructor on a non-alive Foo object. Thus, the behaviour is undefined. If, you replace the delete expression by an explicit call to the global operator delete, it correct this problem:
Foo* p = static_cast(operator new (n * sizeof (Foo))); // calls the global operator new // You can't access Foo members or subtypes here ::operator delete (p); // free the memory
The later code allocates memory with operator new[], which may be the global operator new[], but may also be an overloaded operator new[] by the Foo class. It also constructs all objects, using the default-constructor of Foo (or nothing if Foo is a POD type).
delete[] p, will destroy properly all Foo objects, and release memory with the correct version of operator delete[], which may be overloaded by the Foo class.
9. Why do we use virtual destructor?
http://diamond/exchweb/bin/redir.asp?URL=http://www.geekinterview.com/question_details/19709
http://diamond/exchweb/bin/redir.asp?URL=http://www.codersource.net/cpp_virtual_destructors.html
10. Difference between malloc, calloc and relloc.
http://diamond/exchweb/bin/redir.asp?URL=http://wiki.answers.com/Q/What_is_the_difference_between_malloc_and_calloc_functions
11.can constructors be virtual and why? http://diamond/exchweb/bin/redir.asp?URL=http://www.acetheinterview.com/questions/cats/index.php/cplusplus/2006/10/24/virtual-constructors-by-neetu
http://diamond/exchweb/bin/redir.asp?URL=http://www.geekinterview.com/question_details/36942
12. Static Keyword
http://diamond/exchweb/bin/redir.asp?URL=http://www.cprogramming.com/tutorial/statickeyword.html
13.what is the aggregation and composition..................when it is used and which one is preferred
http://diamond/exchweb/bin/redir.asp?URL=http://www.artima.com/forums/flat.jsp?forum=17%26thread=24715
http://diamond/exchweb/bin/redir.asp?URL=http://ootips.org/uml-hasa.html

14.what is nmake what are the parameters given to it?\
http://diamond/exchweb/bin/redir.asp?URL=http://msdn2.microsoft.com/en-us/library/ms930369.aspx
15.what is copy constructor? its significance? why it is necessary? example...
http://diamond/exchweb/bin/redir.asp?URL=http://www.codersource.net/cpp_copy_constructors.html http://diamond/exchweb/bin/redir.asp?URL=http://en.wikipedia.org/wiki/Copy_constructor
16.difference between reference and pointers. why references are useful?practicle example.
http://diamond/exchweb/bin/redir.asp?URL=http://www.embedded.com/story/OEG20010311S0024
http://diamond/exchweb/bin/redir.asp?URL=http://www.go4expert.com/forums/showthread.php?t=5492
http://diamond/exchweb/bin/redir.asp?URL=http://www.daniweb.com/blogs/entry1664.html

17.what is virtual base class?
http://diamond/exchweb/bin/redir.asp?URL=http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.vacpp7a.doc/language/ref/clrc14cplr135.htm
http://diamond/exchweb/bin/redir.asp?URL=http://www.deitel.com/articles/cplusplus_tutorials/20060225/virtualBaseClass/
18.what are virtual functions? how they get invoked?
http://diamond/exchweb/bin/redir.asp?URL=http://www.parashift.com/c%2B%2B-faq-lite/virtual-functions.html
http://diamond/exchweb/bin/redir.asp?URL=http://en.wikipedia.org/wiki/Virtual_function
19.concepts related to VTABLE.Does classes having non virtual function can have VTABLE?
http://diamond/exchweb/bin/redir.asp?URL=http://www.cauniversity.org/node/382
http://diamond/exchweb/bin/redir.asp?URL=http://gcc.gnu.org/ml/gcc-help/2002-12/msg00280.html

20.what is mutable keyword?when it is used?example... if mutable allows us to change the value of const variable then why we declare it as a const?
http://diamond/exchweb/bin/redir.asp?URL=http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=/com.ibm.xlcpp8l.doc/language/ref/mutable_storage_class_specifier.htm
http://diamond/exchweb/bin/redir.asp?URL=http://www.highprogrammer.com/alan/rants/mutable.html
21.what are volatile variables?when it is used?example...
http://diamond/exchweb/bin/redir.asp?URL=http://publib.boulder.ibm.com/infocenter/macxhelp/v6v81/index.jsp?topic=/com.ibm.vacpp6m.doc/proguide/ref/xviexvvs.htm
http://diamond/exchweb/bin/redir.asp?URL=http://en.wikipedia.org/wiki/Volatile_variable

22.what is the size of empty class?why?
1 Byte
Because compilers are not bound by any rule that says that class size must increase by the size of what is added. If you add an extra byte to an empty class so each object has a distinct address, then you clearly no longer need the extra byte when the class is non-empty. So the compiler discards it (or, more accurately, doesn't add it in the first place).
http://diamond/exchweb/bin/redir.asp?URL=http://www.velocityreviews.com/forums/t268090-re-why-empty-class-size-is-1-byte-.html


23. What is name mangling
http://diamond/exchweb/bin/redir.asp?URL=http://en.wikipedia.org/wiki/Name_mangling


24. What is RTTI and different operators used in that.
http://diamond/exchweb/bin/redir.asp?URL=http://en.wikipedia.org/wiki/Run-time_type_information
25. Which opertors cant be overloaded http://diamond/exchweb/bin/redir.asp?URL=http://www.velocityreviews.com/forums/t286554-operators-that-cannot-be-overloaded-why.html

No comments: