+ 1

Why we use constructor in oops ?

in c++ i can access the member function by creating simple object then why we need to create constructor.

4th Jan 2017, 3:51 AM
Waseem Siddiqi
Waseem Siddiqi - avatar
2 Réponses
+ 4
actually constructors are so usefull sometime we need to create some object which require some input without it the operation will not successfully execute. ex: suppose we are working with graphics then we need a class of Point but with no constructor it is useless,thus must provide a constructor with (int x,int y) values so whenever someone makes an object of this class it will ask for the x & y values.
4th Jan 2017, 4:01 AM
Ashwaghosh Sadanshiv
Ashwaghosh Sadanshiv - avatar
0
Great thanks
4th Jan 2017, 4:09 AM
Waseem Siddiqi
Waseem Siddiqi - avatar