Many thanks for all that assisted in my previous problem. I have one more problem i cannot get my head arround:
I am supposed to say why the following 2 headers are not correct for the function.
#include <iostream>
#include <string>
using namespace std;
void playGame(int numberP, string &gameP, int membersP,int roundsP);
void playGame(int &numberP, string gameP, int &membersP,int roundsP);
int main ()
{
int number = 100;
string game = “poker”;
int members;
int rounds = 6;
playGame(number, “blackjack”, members, 3);
return 0;
}
I know that the string gameP is considdered a constant and in the main its declared as "poker" so that wont work. And i know that numberP in the second header has the same problem. I dont wnat to change the main function, i want to change the headers so that it would work, i tried stepping into it but i keep getting an error that the .exe file cannot be located. i located the file and noticed that it is "empty", in other words it doesnt look the same as other .exe files in the debug folders of other projects. Can anyone assist?
It's hard to tell what you want it to do without seeing the function body, making it difficult to advise.
However, nothing is considered 'constant' in your code. Every data type you have in there is a variable, not a constant. I have a feeling you're referring to the fact that they're passed by reference in some of the parameters.
If you can post the function body and give me an idea of what you want it to do then I'm happy to take a look.
Thanks for coming back to me. Ive been trying to figure out where the declarations go, and assumed it goes in the main function, here is my question, i dont expect an answer for the question, but if i can get it to some sort of level that it can actually debug i can figure what the problem is, functions (and i know how important they are) are not my strong point :)
Consider the following variable definitions and function call:
int number = 100;
string game = “poker”;
int members;
int rounds = 6;
playGame(number, “blackjack”, members, 3);
Consider the two function headers below. For each header, say if you think the header for function
playGame is a valid header, and give reasons for your answer:
1. void playGame(int numberP, string & gameP, int membersP,
int roundsP);
2. void playGame(int & numberP, string gameP, int & membersP,
int roundsP);