Sunday, February 21, 2010

C++ Interview Questions

* Explain the difference between virtual function and virtual inheritance.
* What is the difference between global static functions and static functions, class members.
* What is common and what is the difference between implementations of the copy constructors, initialization and overloaded assignment operators?
* Compare two ways of operator overloading: as a method of class and as an external friend function.
* How to create virtual constructor and destructor in a class?
* Can template class be abstract? Why?
* What is the specificity of overloading sizeof, typeid, new and delete operators?
* Compare distinctive features of overload of operations "()" and "[]".
* Give the detailed comparison of work with strings in C style (char *) and C++ style (string).
* Give the detailed comparison of work with dynamic memory in C and C++.
* Give the detailed comparison of standard input-output facilities in C and C++.
* What does operator throw without parameter mean?
* Tell about the kinds of iterators you know and the difference between them.
* What is the difference between modifiers register, const and volatile?
* How to write the function takes unknown number of arguments?
* What is the difference between constructions extern and extern "C"?
* In traditional C++, what's the difference between using and include?
* Compare use of macros, inline-functions and template-functions.
* How can you competently organize nontrivial sorting using tools of standard C and C++ libraries (compare the approaches)?
* Tell what and how you can do to be able to put class objects into cout and read them from cin?
* Compare various forms of type cast operations (in C and C++ styles). Tell about overloading of these operations.
* Each class has some special member-functions, which calls can be inserted by the compiler into a code without explicit instruction of the programmer. Enumerate such functions, members and cases, when implicit calls can arise.
* How to set default values of function arguments? What are pros and contras of use of this C++ opportunity? What's its alternative?
* When writing catch operator we can write directly type of exception as a type of its argument, pointer to a type of exception or reference to a type of exception. Compare these approaches.
* In what order function arguments are evaluated at its call: from left to right, from right to left or any other way? For example, in what order will the arguments in the following example be calculated: f(5+I, ++I); ?

* If when creating a variable the programmer explicitly did not initialize it, in some cases, the compiler itself would give it a certain, predefined initial value, and in some cases the initial value would be unpredictable. What does it depend on?
* What does the order of creation (sequence of constructors call) of global variables depend on? What practical conclusions can be made from this fact?
* There is a code:
f(){return 3.5;}
...
double d = f()
What is the value d equal to and why?
* Explain the difference between anonymous namespace and anonymous enumeration.
* What will happen, if the exception is thrown from the constructor?
* What is the templates specialization and what is its application?
* What is the specifity of application of operator delete to the function pointers?
* What is this? How is this used?
* What the forward declaration of classes is used for?
* What preprocessor directives are usually used to prevent multiple inclusion of the header file?
* What constructions does C++ offer to programmers for organization of branches?
* What constructions does C++ offer to programmers for organization of loops?
* What is polymorphism? What constructions in C++ allow to say that this language supports polymorphism? What polymorphism is used for?
* What is lvalue?
* What the finally keyword is used for in C++?
* Compare operators continue and break.
* What trigraphs are and what are they necessary for?
* What is the difference and what is common in specifity of constructors and destructors overloading?
* What is anonymous union and how is it used?
* Is it possible (if yes - than how) to write such a class in C++ that no class could be inherited from it?
* There are two classes given, one of which is the successor from another. Write how should the constractors of copying-initialization for these classes look (make an example).
* What's the specifity of operations "||" and "&&"? What's the specifity of these operations overload?
* Compare "static variable" and "static variable as a member of a class".
* What's the danger of using macroses? Show that on examples.
* Compare operators throw and return.
* How to initialize a variable which is a private static member of a class?
* What does auto_ptr class stand for and how is it used?

No comments:

Post a Comment