Hi
Can somebody please explain to me the following error and how to fix it
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void processMarks (string studentP, int & assgnmntP, int & markP,
bool doneP)
{
;
}
int main()
{
string student;
int mark;
int assignment;
bool done = false;
processMarks("Sally Williams", 1, mark, done);
}
error: invalid initialization of non-const reference of type 'int&' from a temporary of type 'int'|
error: in passing argument 2 of 'void processMarks(std::string, int&, int&, bool)'|
This means that an object exists outside of this function and we can manipulate it.
However, in our main we call it with: processMarks("Sally Williams", 1, mark, done);
When we type the integer 1, we are not creating an object. It has no address and so we also cannot manipulate it.