Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualNightCreature83

Posted 06 November 2012 - 05:51 AM

void reverseString(char* const src, char** reversed)
{
	 *reversed = new blah;
}

char *reversed = NULL;
reverseString(blah, &reversed);

The C++ way would be to use a reference to a pointer so that you can just assign to it in the function if you want to keep the interface the same. And would look like this:
void reverseString(char* const src, char*& reversed)
{
	 reversed = new blah;
}
char *reversed = NULL;
reverseString(blah, reversed);

#1NightCreature83

Posted 06 November 2012 - 05:48 AM

void reverseString(char* const src, char** reversed)
{
	 *reversed = new blah;
}

char *reversed = NULL;
reverseString(blah, &reversed);

The C++ way would be to use a reference to a pointer so that you can just assign to it in the function if you want to keep the interface the same.

PARTNERS