Question
What is the difference between storing a function call in a variable versus storing the value returned by a function in a variable in C++?
What is the difference between storing a function call in a variable versus storing the value returned by a function in a variable in C++? For example
int LowStake::payOut(int &totalRand, int &creditPaidOut) { if (totalRand <= 14 || totalRand > 20) { creditPaidOut = buyIn * 0; } else if (totalRand == 15) { return (creditPaidOut * 0.25); } else if (totalRand == 16) { return (creditPaidOut * 0.5); } else if (totalRand == 17) { return creditPaidOut; } else if (totalRand == 18) { return (creditPaidOut * 1.25); } else if (totalRand == 19) { return (creditPaidOut * 1.5); } else { return (creditPaidOut * 2); } return creditPaidOut; }
int x = Payout();
int y = creditPaidOut
When I cout x and y i don't have a value rather I am instead seeing something which looks like a memory address.
Help please
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started