C++ Interview Questions and Answers

What is C++?

C++ is an object-oriented programming language created by Bjarne Stroustrup in 1985.

What are the differences between C and C++?

C++ is a superset of C language.

C is a procedural programming language, but C++ supports both procedural and Object Oriented programming.

In C++ can use access modifier to restrict access of member function and variable to outside class and user, but in C we can’t do that.

What are the differences between C++ and Java?

C++ has pointers, but Java does not support pointer.
Java is platform-independent, but C++ is not.
Java has garbage collection, but C++ does not.
C++ used complier but Java uses interpreter.
C++ support operator overloading and multiple inheritance but Java not support both.

Explain is Object Oriented Programming (OOP)?

Object-oriented programming is a techniques for managing enormous complexity, achieving reuse of software components, and coupling data with the procedures that work on that data as a single "object"--a self-contained entity.

The basic concepts of Object Oriented Programming are given below:
Class and Object: Class is a template and implementation of entities whereas Object is variable and representation of class.
Encapsulation and data hiding: the binding of data and methods together called Encapsulation, where hide the data or direct access from outside known as data hiding.
Inheritance: Inheritance is concept of reusability and can used this to inherit the property of one class into another class.
Polymorphism: Poly means many, and morph means form. Polymorphism refers to the same name taking many forms or can perform different task depend on context.

What is a class in C++?

Class is a user-defined data type. It can consist of any combination of the variable types and also other class types.
The variables in the class are referred to as the member variables or data members and the functions in the class referred to as member Functions or methods of the class.

What is an object?

An object is an individual instance of a class and also called a class variable.
It can access the class members and functions by using the dot (.) operator.

Define the private, public and protected in C++?

Private, Public and protected and are three access specifier in C++.

Private: All members of a class data and methods are private by default. Private members can be accessed only within methods of the class itself.
Public: Public members can be accessed through any object of the class.
Protected: data members and member functions are only available to derived classes.

Explain constructor?

Constructors is special member function of class with the same name as the class and it used to create and initialize Object.
The constructor can take parameters as needed, but it cannot have a return value--not even void.
We can do Overloading of Constructor.

Explain destructor?

Destructors always has the name of the class, preceded by a tilde (~) and clean up allocated memory. Destructors take no arguments and have no return value.
We cannot Overload of destructor.

What is Default Constructors and Destructors?

If we don't declare a constructor or a destructor manually, the compiler makes one for you. The default constructor and destructor take no arguments and do nothing.

What is a copy constructor?

A copy constructor is the constructor which copies the exact values of one object's member variables into another object.
Copy constructors take one parameter, which a reference to an object of the same class.

Explain the static variable and member function?

Static variables and member functions belonging to the class rather than to the object. Normal member data is one per object, but static members are one per class and they can be called without having an object of that class.


Latest Updates

Ratio and Proportion

A certain sum of money is divided between A and B in the ratio of 5/4 : 5/3 and A got Rs. 360/-. Find the total sum of money and B’s share?

In an office, the ratio of the salaries of an officer and a clerk is 15:7. If the salary of a clerk is Rs. 720/- less than the salary of the officer, find the salary of each?

In an election to a municipal council, the votes secured by two candidates are in the ratio 13:19. The elected candidates gets 312 votes more than the second candidate. How many votes are secured by the second candidate?

A certain sum of money is divided between Murthy and Prasad in the ratio 22/7 : 8/3. If Murthy gets Rs. 120/- more than Prasad, find the share of each?

In a cricket test series, the runs made by Raju and Tendulkar are in the ratio 5:9 and Tendulkar and Azar are in the ratio 6:7. What are the runs made by them if Azar makes 187 runs more than Raju?

If A:B = 2:3 and B:C = 9:5 find A:B:C?

If A:B = 3/5:5/7 and B:C = 3/4:2/5, find A:B:C?

If R:S = 0.01:0.11 and S:T = 2.2:1, Find R:S:T?

In a school, Under a Saving Scheme, Rekha saves 3/2 times the savings of Bindu, Geeta saves 4 times the savings of Rekha. Find the ratio of the savings of all the three in least terms?


A man left 1/3 rd of his property to his wife and 3/5 th of the remainder to his daughter. He gave the rest to his son who received Rs. 6400/-. How much was his original property worth?

Ratio and Proportion

In a school 4/9 of the pupils are boys. There are 125 girls. How many boys are there?

If A:B = 3:4 and B:C = 5:6, find A:C?

IF X:Y = 3:4 AND Y:Z = 4:5, FIND X:Y:Z?


A house site is in the shape of a square. Its area is 1225 sq metres. What is its perimeter?

The area of a square field is 7396 sq metres. Find its perimeter?


Twice the first of three consecutive even integer is 6 more than the second integer. What is the third integers?

Ratio and Proportion

If 2x=3y and 4y=5z, then what is x:z=?

What quantity must be added to each term of the ratio a + b : a – b to make it equal to (a + b)2 : (a – b)2 ?