Can anyone explain me in simple language and better if with an example why constructor don't have return types :!:
SpS
34
Posting Pro
Recommended Answers
Jump to PostProbably because the are not explicitely called in your code, so what good would it do to return a value -- nobody is going to be listening.
The constructor is only called when you instantiate an object. There is no way to catch the return value of the constructor.
…
Jump to Post>Can anyone explain me in simple language and better if with an
>example why constructor don't have return types
Here's an idea. Show us how it could be done without breaking all kinds of existing code, and you'll answer your own question.
Jump to Post...can u explain me this....
Nope. I don't know what taking the address of a function has to do with returning a value. constructors don't return values because c++ standards and language say they don't. ;)
All 10 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Narue
5,707
Bad Cop
Team Colleague
SpS
34
Posting Pro
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Dante Shamest
0
Light Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Dante Shamest
0
Light Poster
mohit_verma
0
Newbie Poster
corby
-4
Junior Poster
ishan_1
-3
Newbie Poster
jwenting
commented:
zombie spammer
-3
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.