pointers - Manipulating data members (C++) -
i have method takes object argument.
both caller , argument have same members (they instances of same class).
in method, particular members compared , then, based on comparison, 1 member of argument object needs manipulated :
class object { // members public: somemethod (object other) { int result; member1 - other.member1 = result; other.member2 = other.member2 - result; }
the thing doesn't change other.member2 out of scope, , change needs permanent.
so yes, sorry: need advice on pointers... have looked online , in books, can't working. figure 1 of @ , know answer in 30 seconds. have rftm , @ stupid loss. not encouraging.
thanks everyone!
this because passing value (which equates passing copy. think of making photocopy of document , asking them make changes, still have original changes make won't reflected in copy when back. but, if tell them copy located, can go , make changes see next time go access it). need pass either reference object with
object& object
or pointer object
object * object
check out this page discussion of differences.
Comments
Post a Comment