Hi there, I am tryign to write a function and i need part of it to access and change the variables of an object (seems simple enough)
I create the object using
Code:
canyon_section result(0,0);
in the main() function of a .cpp file.
Below is the constructor for the object:
Code:
class canyon_section
{
public:
canyon_section( int first_value, int second_value )
: first_value_( first_value ),
Second_value_( second_value )
{
}
This object 'result' is then passed by reference to a function in a header file:
Code:
next_section_result = get_next_section(result);
i then use the code:
Code:
result.first_value = random_int();
result.second_value = random_int();
to try and modify the 2 integer values of the object.
Only problem is when I try to compile the main.cpp file I get a compile error:
'invalid use of member (did you forget the `&' ?) '
with a line reference to the 'result.first_value.....' line (same error for the second_value line as well).
Am i missing something?
Thanks,
stu673
*edited to include funciton call & constructor