K
Kavya
I was reading a book Test Your C++ Skills by Yashwant Kanetkar. There
was a question in it
Ques: Why constructors do not have return values?
Ans :Constructors are called whenever an object is created. And there
can never exist a situation where we want to return a value at the time
of creation of an object.
I don't understand why author says that.
What if I want to check whether the object is successfully created. We
could have checked that by returning some value and finding it.
was a question in it
Ques: Why constructors do not have return values?
Ans :Constructors are called whenever an object is created. And there
can never exist a situation where we want to return a value at the time
of creation of an object.
I don't understand why author says that.
What if I want to check whether the object is successfully created. We
could have checked that by returning some value and finding it.