0
What's the difference between a constructor and a function?
3 Respuestas
+ 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.
+ 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
+ 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