Welcome,  Guest  |  Sign In |  New User? 

List of C++ Interview Questions & Answers

Page 1 of 11: 1 2 3 4 5 6 7 8 9 10 Next>>

What is an orthogonal base class?         [ 48 ]

 If two base classes have no overlapping methods or data they are said to be independent of, or orthogonal to each other. Orthogonal in the sense means that two classes operate in different dimensions and do not interfere with each other in any way. The same derived class may inherit such classes with no difficulty.

Choose your rating:    Post Ans.    View More Ans.

Name some pure object oriented languages.         [ 58 ]

 Smalltalk, Java, Eiffel, Sather. 

Choose your rating:    Post Ans.    View More Ans.

What are the conditions that have to be met for a condition to be an invariant of the class?         [ 43 ]

 * The condition should hold at the end of every constructor.
* The condition should hold at the end of every mutator (non-const) operation.


Choose your rating:    Post Ans.    View More Ans.

Define precondition and post-condition to a member function.         [ 50 ]

 Precondition: A precondition is a condition that must be true on entry to a member function. A class is used correctly if preconditions are never false. An operation is not responsible for doing anything sensible if its precondition fails to hold. For example, the interface invariants of stack class say nothing about pushing yet another element on a stack that is already full. We say that isful() is a precondition of the push operation. Post-condition: A post-condition is a condition that must be true on exit from a member function if the precondition was valid on entry to that function. A class is implemented correctly if post-conditions are never false. For example, after pushing an element on the stack, we know that isempty() must necessarily hold. This is a post-condition of the push operation.

Choose your rating:    Post Ans.    View More Ans.

What is a Null object?         [ 75 ]

 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. 

Choose your rating:    Post Ans.    View More Ans.

What is an Iterator class ?         [ 47 ]

 A class that is used to traverse through the objects maintained by a container class. There are five categories of iterators: input iterators, output iterators, forward iterators, bidirectional iterators, random access. An iterator is an entity that gives access to the contents of a container object without violating encapsulation constraints. Access to the contents is granted on a one-at-a-time basis in order. The order can be storage order (as in lists and queues) or some arbitrary order (as in array indices) or according to some ordering relation (as in an ordered binary tree). The iterator is a construct, which provides an interface that, when called, yields either the next element in the container, or some value denoting the fact that there are no more elements to examine. Iterators hide the details of access to and update of the elements of a container class.
The simplest and safest iterators are those that permit read-only access to the contents of a container class.
 

Choose your rating:    Post Ans.    View More Ans.

What is the use of ‘using’ declaration. ?         [ 44 ]

 A using declaration makes it possible to use a name from a namespace without the scope operator.

Choose your rating:    Post Ans.    View More Ans.

When does a name clash occur?         [ 46 ]

 A name clash occurs when a name is defined in more than one place. For example., two different class libraries could give two different classes the same name. If you try to use many class libraries at the same time, there is a fair chance that you will be unable to compile or link the program because of name clashes.

Choose your rating:    Post Ans.    View More Ans.

What is an accessor?         [ 49 ]

 An accessor is a class operation that does not modify the state of an object. The accessor functions need to be declared as const operations

Choose your rating:    Post Ans.    View More Ans.

What is a modifier?         [ 59 ]

 A modifier, also called a modifying function is a member function that changes the value of  at least one data member. In other words, an operation that modifies the state of an object. Modifiers are also known as ‘mutators’. Example: The function mod is a modifier in the following code snippet:

class test
{
int x,y;
public:
test()
{
x=0; y=0;
}
void mod()
{
x=10;
y=15;
}
};


Choose your rating:    Post Ans.    View More Ans.

Page 1 of 11: 1 2 3 4 5 6 7 8 9 10 Next>>