what is constructor | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what is constructor

give example with details

30th Jun 2017, 7:11 PM
‎ ‏‏‎Anonymous Guy
2 Answers
+ 2
class qae { qae() { cout<<"constructor"<<endl; } }; void main() { qae b(); } output: constructor
1st Jul 2017, 5:40 AM
Zaka Ahmad Chishti
Zaka Ahmad Chishti - avatar
+ 1
Constructor is automatically called when new object is created. Its name is same to class name.
1st Jul 2017, 5:36 AM
Zaka Ahmad Chishti
Zaka Ahmad Chishti - avatar