The Hot C++ Interview Question Asked

The Hot C++ Interview Question: 

How do you rank your C++ skills on a scale of 1 to 10?

This is often the first question you will hear on an interview for a C++ contract. You will be tempted to rate yourself high, and you should. This is your chance to convince the client that you are just what he is looking for–an assertive and knowledgeable professional who will be productive either working on a team or on your own. Naturally, though, you should be able to support the ranking you gave yourself by doing well on the interview.

Q1. Is there anything you can do in C++ that you cannot do in C?

A1. No. There is nothing you can do in C++ that you cannot do in C. After all you can write a C++ compiler in C.

Q2. What is the difference between C++ structure and C++ class?

A2. The default access level assigned to members of struct is public while the default access level assigned to a class is private.

Q3. What is encapsulation? A3. Encapsulation is welding of code and data together into objects.

Q4. What is inheritance?

A4. Inheritance is a mechanism through which a subclass inherits the properties and behavior of its superclass.

Q5. What is polymorphism?

A5. In Greek this means “many shapes.” As a consequence of inheritance and virtual functions, a single task (for example, drawing a geometrical shape) can be implemented using the same name (like draw()) and implemented differently (via virtual functions) as each type in object hierarchy requires(circle.draw() or rectangle.draw()). Later, when a polymorphic object (whose type is not known at compile time) executes the draw() virtual function, the correct implementation is chosen and executed at run time.

Q6. What would you say if you saw “delete this” while reviewing your peer’s code?

A6. You should never do this. Since compiler does not know whether the object was allocated on the stack or on the heap, “delete this” could cause a disaster.

Q7. What is the difference between public, protected, and private members of a class?

A7. Private members are accessible only by members and friends of the class. Protected members are accessible by members and friends of the class and by members and friends of derived classes. Public members are accessible by everyone.

Q8. What is the difference between non-virtual and virtual functions?

A8. The behavior of a non-virtual function is known at compile time while the behavior of a virtual function is not known until the run time.

Q9. What is a pure virtual function?

A9. “A pure virtual function is a function declared in a base class that has no definition relative to the base.”

Q10. What is an abstract base class?

A10. It is a class that has one or more pure virtual functions.

2 Responses to “The Hot C++ Interview Question Asked”

  1. Key Says:

    Thank you for this post. More questions can be found at

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: