Computer Science, asked by pushkar1905, 1 year ago

why do we need a constructor as a class member​

Answers

Answered by yugparikh
2

Answer:

we need constuctor to the class because he knws how to give shape and the size to the class

Answered by CopyThat
1

Explanation:

  • Whenever an object is created, it must be constructed usually with legal initial values automatically without being specified by the programmer. This will  immensely relieve the programmer from initializing values of objects for large programs and hence the need for constructor.

Constructor:

  • Constructor is a function that have the same name as the class and is  automatically invoked during creation of an object.
Similar questions