![]() |
VOOZH | about |
In C++, a constructor is a special member function that is automatically called when an object of the class is created.
In the below class, a default constructor will be generated by the compiler at compile time.
In this example, a constructor with no parameters is explicitly defined. Since a constructor already exists, the compiler will not generate one.
Objects of this class can be created without arguments.
You can also initialize class members inside the default constructor.
Explanation:
Default constructor called Name: Unknown, Roll: -1
Explanation