What are the constructors and destructors in C++?? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 6

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

šŸµšŸŒ¼šŸ’šŸŒøšŸ’®šŸµšŸ’šŸŒøšŸŒ¼

15th Apr 2019, 7:52 AM
Nithya Yamasinghe
Nithya Yamasinghe - avatar
3 Respostas
+ 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