why constructor use, why not always use simple initialization of variables?

后端 未结 2 1025
情歌与酒
情歌与酒 2020-12-12 04:25

I have searched about this lot and get this answer on stack overflow given answer here

  • That states that we can use both constructor and simple initiali
2条回答
  •  孤城傲影
    2020-12-12 05:10

    To create a new object,we have to run the constructor.If we create default constructor compiler automatically add default constructor.But when we want to run paramaetrized constructor we have to define in the class..

提交回复
热议问题