Monday, 17 September 2012

C++ Interview Questions-3



31. What problem does the namespace feature solve?
Ans: Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries. The namespace feature surrounds a library’s external declarations with a unique namespace that eliminates the potential for those collisions. This solution assumes that two library vendors don’t use the same namespace identifier, of course.

32. What is the use of ‘using’ declaration?
Ans: A using declaration makes it possible to use a name from a namespace.

33. What is a template?
Ans: Templates allow us to create generic functions that admit any data type as parameters and return a value without having to overload the function with all the possible data types. Until certain point they fulfill the functionality of a macro. Its prototype is any of the two following ones:
template function_declaration;
template function_declaration;

34. Differentiate between a template class and class template?
Ans:
Template class:
A generic definition or a parametrized class not instantiated until the client provides the needed information. It’s jargon for plain templates.
Class template:

A class template specifies how individual classes can be constructed much like the way a class specifies how individual objects can be constructed. It’s jargon for plain classes.

35. What is the difference between a copy constructor and an overloaded assignment operator?
Ans: A copy constructor constructs a new object by using the content of the argument object. An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class.

36. What is a virtual destructor?
Ans: The simple answer is that a virtual destructor is one that is declared with the virtual attribute
.
37. What is an incomplete type?
Ans: Incomplete type refers to pointers in which there is non availability of the implementation of the referenced location or it points to some location whose value is not available for modification.
Example:
int *i=0×400 // i points to address 400
*i=0; //set the value of memory location pointed by i.
Incomplete types are otherwise called uninitialized pointers.

38. What do you mean by Stack unwinding?
Ans: It is a process during exception handling when the destructor is called for all local objects between the place where the exception was thrown and where it is caught.

39. What is a container class? What are the types of container classes?
Ans: A container class is a class that is used to hold objects in memory or external storage. A container class acts as a generic holder. A container class has a predefined behavior and a well-known interface. A container class is a supporting class whose purpose is to hide the topology used for maintaining the list of objects in memory. When a container class contains a group of mixed objects, the container is called a heterogeneous container; when the container is holding a group of objects that are all the same, the container is called a homogeneous container.

40. Name some pure object oriented languages?
Ans: Smalltalk, Java, Eiffel, Sather.

1 comment:

  1. Hi There,


    So bloody thorough! Ah! So happy and blessed out! I feel redeemed by reading out knowledge guide for All Keep up the good work!

    how to resolve these conflicting data types in C# and C.I need to send string data
    from my Graphic User Interface to the microcontroller which was programmed in C.Below are the lines of code.

    CODE OBJECTIVE: To use the slider(track bar) in Visual Studio Express to vary the brightness of Leds
    C# codes

    But nice Article Mate! Great Information! Keep up the good work!


    Regards,
    Hansy

    ReplyDelete