Void return type and no return type



Constructor and Destructor have "no return" type not even "void".
What is difference between void return type and no return type in C++
because void also returns nothing ??
I found something written like : "For Void return value function returns nothing but still have the option to make it something else"....... Pls someone explain it what this statement means.... Thanks
I have no idea, I think the statement is not clear enough.

Anyway, functions with return type void basically mean they don't return a value. Constructors and Destructors are a bit different than functions. Constructors and Destructors can't return values, therefore, it would be unnecessary to write "void" everytime.
Constructors and Destructors are unique in not specifying a return type.

In a ctor or dtor, you _cannot_ return something, even if you would like to. All other functions you _could_ return something if you chose to do so.

If you really need to return something when constructing an object, you can use the named constructor idiom.
Thank you forl the replies they have been very useful :)
Topic archived. No new replies allowed.