0

What's the difference between a constructor and a function?

12th Apr 2022, 4:51 PM
Biagio
3 Answers
+ 4
Biagio we use constructor when dealing with objects, it is used to give an objects some basic functionalities, common to all class object instances. function consists a block of codes designed for some specific task.
12th Apr 2022, 5:24 PM
NonStop CODING
NonStop CODING - avatar
+ 2
"Class constructors are special member functions of a class. They are executed whenever new objects are created within that class." Lesson 53, c++ course in sololearn
12th Apr 2022, 5:03 PM
Lisa
Lisa - avatar
+ 1
Biagio Constructor is a function indeed, named exactly as class name and used only when new object is "born" šŸ™‚ āŽYou can't use constructor for something else to return something like in ordinary functions
13th Apr 2022, 11:52 PM
Ilyas Bakirov
Ilyas Bakirov - avatar