C++ is an enhanced version of the C language. C++ includes everything that is part of C and adds support for object- oriented programming (OOP). In addition, C++ also contains many improvements and features that make it a "better C", independent of object oriented programming. C++ is actually an extendible language since we can define new types in such a way that they act just like the predefined types which are part of the standard language.
If you just use C++ as a better C, you will not be using all of its power. Like any quality tool, C++ must be used the way it was designed to be used to exploit its richness. Some of the new features include encapsulation, inline function calls, overloading operators, inheritance and polymorphism. I am not going to explain what they mean here as that would simply take me away from my purpose here, but you can refer to any good C++ book or the C++ FAQ for more information.
C++ Language Interviews are getting tough these days as the technology grows faster. To get through the C++ Language interview one needs to update him/herself in a regular manner. Having said that, just before the interview, it is very important to have a quick glance of the reputed C++ Language questions and answers to make yourself comfortable during the interview process. This is where DoAnswers.com helps you in renewing yourself on C++ Language and various other technologies interview preparation.
1. Can a constructor throw a exception? How to handle the error when the constructor fails?
The constructor never throws a error.
2. Can inline functions have a recursion?
No. Syntax wise It is allowed. But then the function is no longer Inline. As the compiler will never know how deep the recursion is at compilation time.
3. Can you think of a situation where your program would crash without reaching the breakball, which you set at the beginning of main()?
C++ allows for dynamic initialization of global variables before main() is invoked. It is possible that initialization of global will invoke some function. If this function crashes the crash will occur before main() is entered.
4. Define namespace.
It is a feature in C++ to minimize name collisions in the global name space. This namespace keyword assigns a distinct name to a library that allows other libraries to use the same identifier names without creating any name collisions. Furthermore, the compiler uses the namespace signature for differentiating the definitions.
5. Differentiate between a template class and class template.
Template class: A generic definition or a parameterized class not instantiated until the client provides the needed information. It?s jargon for plain templates. Class template: A class template specifies
6. Differentiate between the message and method.
Message: Objects communicate by sending messages to each other. A message is sent to invoke a method. Method Provides response to a message. It is an implementation of an operation.
7. does not exist. One common use for a null object is a return value from
a member function that is supposed to return an object with some specified properties but cannot find such an object.
8. does not modify the state of an object. The accessor functions need to
be declared as const operations
9. Explain the ISA and HASA class relationships. How would you implement each in a class design?
A specialized class "is" a specialization of another class and, therefore, has the ISA relationship with the other class. This relationship is best implemented by embedding an object of the Salary class in the Employee class.
10. Explain the scope resolution operator?
It permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope.