Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

C++ Interview Questions and Answers

Test your skills through the online practice test: C++ Quiz Online Practice Test

Related differences

C vs C++Java vs C++

Ques 26. What is an object?


Object is a software bundle of variables and related methods. Objects have state and behavior.

Is it helpful? Add Comment View Comments
 

Ques 27. How can you tell what shell you are running on UNIX system?


You can do the Echo $RANDOM. It will return a undefined variable if you are from the C-Shell, just a return prompt if you are from the Bourne shell, and a 5 digit random numbers if you are from the Korn shell. You could also do a ps -l and look for the shell with the highest PID.

Is it helpful? Add Comment View Comments
 

Ques 28. What do you mean by inheritance?


Inheritance is the process of creating new classes, called derived classes, from existing classes or base classes. The derived class inherits all the capabilities of the base class, but can add embellishments and refinements of its own.

Is it helpful? Add Comment View Comments
 

Ques 29. Describe PRIVATE, PROTECTED and PUBLIC ? the differences and give examples.

class Point2D{
int x; int y;

public int color;
protected bool pinned;
public Point2D() : x(0) , y(0) {} //default (no argument) constructor
};

Point2D MyPoint;

You cannot directly access private data members when they are declared (implicitly) private:

MyPoint.x = 5; // Compiler will issue a compile ERROR
//Nor yoy can see them:
int x_dim = MyPoint.x; // Compiler will issue a compile ERROR

On the other hand, you can assign and read the public data members:

MyPoint.color = 255; // no problem
int col = MyPoint.color; // no problem

With protected data members you can read them but not write them: MyPoint.pinned = true; // Compiler will issue a compile ERROR

bool isPinned = MyPoint.pinned; // no problem

Is it helpful? Add Comment View Comments
 

Ques 30. What is namespace?


Namespaces allow us to group a set of global classes, objects and/or functions under a name. To say it somehow, they serve to split the global scope in sub-scopes known as namespaces.
The form to use namespaces is:
namespace identifier { namespace-body }
Where identifier is any valid identifier and namespace-body is the set of classes, objects and functions that are included within the namespace. For example:
namespace general { int a, b; } In this case, a and b are normal variables integrated within the general namespace. In order to access to these variables from outside the namespace we have to use the scope operator ::. For example, to access the previous variables we would have to put:
general::a general::b
The functionality of namespaces is specially useful in case that there is a possibility that a global object or function can have the same name than another one, causing a redefinition error.

Is it helpful? Add Comment View Comments
 

5) What is namespace? " />

Most helpful rated by users:

©2024 WithoutBook