well my question is:
if i want to return something from a void how do i do that like:
how?Code:void calculater()
{
cout << "5+5=";
return 10;
}
int main()
{
int number=calculater();
cout <<number;
getchar();
}
Printable View
well my question is:
if i want to return something from a void how do i do that like:
how?Code:void calculater()
{
cout << "5+5=";
return 10;
}
int main()
{
int number=calculater();
cout <<number;
getchar();
}
you don't. you change the return type
how cna you give me a clue?
Code:int calculator()
{
//...
}
You can not do that.
void specifically means no return
if you wan't to return an integer, just declare your function to return an integer:
Also please indent code when you post it. :)Code:int MyFunction()
{
cout << "My Statement";
return 10;
}
oh thx you, can you return a string to?`;D
You can return a pointer to a char, or you could accept a pointer as an argument and manipulate that string.
ok well then how do i recieve my things i have returned?
man i maybe like this forum :D
thx ;D. Thread complete and closed :D
you should really do the tutorials.