Using a constructor for return.
Posted
by Fecal Brunch
on Stack Overflow
See other posts from Stack Overflow
or by Fecal Brunch
Published on 2010-04-15T03:22:07Z
Indexed on
2010/04/15
3:33 UTC
Read the original article
Hit count: 292
Hi, Just a quick question.
I've written some code that returns a custom class Command, and the code I've written seems to work fine. I was wondering if there are any reasons that I shouldn't be doing it this way. It's something like this:
Command Behavior::getCommand ()
{
char input = 'x';
return Command (input, -1, -1);
}
Anyway, I read that constructors aren't meant to have a return value, but this works in g++.
Thanks for any advice,
Rhys
© Stack Overflow or respective owner