C++ Interview Questions and Answers
Ques 101. What is an incomplete type?
Incomplete types 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.
int *i=0x400 // i points to address 400
*i=0; //set the value of memory location pointed by i.
Incomplete types are otherwise called uninitialized pointers.
Ques 102. What is a dangling pointer?Ans.
A dangling pointer arises when you use the address of an object after
its lifetime is over. This may occur in situations like returning
addresses of the automatic variables from a function or using the
address of the memory block after it is freed. The following
code snippet shows this:
ptr = new int(i);
cout << "The value is " << *ptr;
void SomeFunc(Sample x)
cout << "Say i am in someFunc " << endl;
Sample s1 = 10;
In the above example when PrintVal() function is
called it is called by the pointer that has been freed by the
destructor in SomeFunc.
Ques 103. Differentiate between the message and method.
* Objects communicate by sending messages to each other.
* A message is sent to invoke a method.
* Provides response to a message.
* It is an implementation of an operation.
Ques 104. What is an adaptor class or Wrapper class?Ans.
A class that has no functionality of its own. Its member functions hide the use of a third party software component or an object with the non-compatible interface or a non-object-oriented implementation.
Ques 105. What is a Null object?Ans.
It is an object of some class whose purpose is to indicate that a real object of that class 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.
4) What is an adaptor class or Wrapper class? 5) What is a Null object? " />
Most helpful rated by users: