[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] pointers and addresses
Hi,
I have created a new header. In this header, I have a field integer num_. I can
change its value in my main program with the two lines :
hdr_rack* cr= (hdr_rack*)p->access(off_rack_);
cr->num()=value;
because, in my header, I have defined the function num() like this :
int& num() {return num_;}
But now, I would like to do the same with a pointer ptr_s_ to a structure.
I tried this :
dyn_rack *ptr_s_;
dyn_rack* ptr_s() {return ptr_s_;}
but when I try to change the value of this pointer in my main program, I have an
error :
non-lvalue in assignment
So could anybody show me the line to type to define the correct function in my
header so I could change the value of the pointer ( ex.: so I could have the
equivalency of ptr_s=malloc ... but with the function defined in my header as
with num(), I want num=5, I write cr->num()=5 ).
Thank you.
Jan.