Category: C++ Basic

C++ Basic interview questions and answers with example asked in IT Industries. List of C++ interview questions or for freshers and experienced both | Only Real.

Explain function overloading in C++ with its return type and signature.

Answer: Function overloading in C++ is the feature of having multiple functions in a class with same name with different return types and signatures. For example in below class we have three functions overloaded.     Function overloading is a compile time polymorphism and function calls are resolved at compile time itself. It is important…

Read the full article

Can we have default arguments in constructor in C++?

Answer: Yes, we can have default arguments in constructor in C++. Below class “MLogger “ example contains default argument in constructor i.e. MLogger(bool isON = false). This is the pseudo code for logging errors, that logs errors if object has been created with “true” value i.e. MLogger LogOn(true);, so, constructor will accept the value true…

Read the full article

Tell me properties of destructor in C++ as many as you can.

Answer includes properties / characteristics of destructor in C++ language for a class. Answer: Before listing characteristics of destructor, let’s see the declaration of destructor in  a class. Below ~MyClass() is the destructor of a class.   Properties of destructor in C++: It is called automatically when class object goes out of scope or when…

Read the full article