when constructors are called in c++

Whenever we create object of a class then default constructor will be called automatically. If we don’t define constructor in our class then there is hidden default constructor which is not seen, but we may override this.

Example

#include <iostream>
using namespace std;

class A
{
public:

	// overriding default constructor
	A()
	{
		cout << "default call" << endl;
	}
};

int main()
{
	A ab;
	getchar();
	return 0;
}

Output

default call