Constructor
Constructor in C++ is a special non-static member function of a class that is used to initialize objects of its class type as cpp reference say.
it means Constructors dose not construct anywhere, Constructor is just invoked at the time of object creation.
Constructor is just function that is invoked automatically at the time of object creation. so you can invoke other function in constructor.
example
ClassName::init(const int& id_in) // other function
{
m_id = id_in;
}
ClassName::ClassName() // constructor
{
init(42);
}
Top comments (1)
good