C++
Constructor and Destructor in C++
seoca
2018. 11. 6. 15:28
Constructor and Destructor with simple example code
- Constructors are called as soon as an object is created
- It does not have a return type and has the same name as class name.
- In case there is no constructor or destructor, the compiler creates default constructor or destructor but if there is at least one constructor, the default constructor is not created by default.
- They both have to be public.
- A class allows multiple constructors but destructor must be the one.
example code
Result