+ 6

What are the constructors and destructors in C++??

🏵🌼💐🌸💮🏵💐🌸🌼

15th Apr 2019, 7:52 AM
Nithya Yamasinghe
Nithya Yamasinghe - avatar
3 ответов
+ 7
Constructors allocate memory for objects and initialize them. Destructors free the memory and other resources.
15th Apr 2019, 11:15 PM
Sonic
Sonic - avatar
+ 4
Constructors do not allocate memory for objects (that's done with 'new'). They are used to initialize an object (instance of a class) with an valid state.
16th Apr 2019, 12:04 PM
Daniel Adam
Daniel Adam - avatar