S
sangeetha
Hello,
I'm passing a RWList object of one complex data to function f(). In
the function f() i'm receiving in that list as reference. In the
function f(), i want to modify one member variable in all the nodes in
that input RWList. I've written following (dummy)code to do produce my
problem. The values modified in the function are not reflected in the
called function. I spend sometime not able to find/resolve the
problem...
class A{
public:
const RWString & x( return _x;}
const RWstring & y( return _y;}
void x(const RWStrng & value) { _x = value; }
void y(const RWStrng & value) { _y = value; }
private:
RWString _x;
RWString _y;
};
void f ( RWList<A>& alist) // receiving as reference of that list
{
RWListIter<A> AIter(alist);
while (AIter())
{
A &a = AIter.key(); // storing as reference
a.x("xxxxxxxxx");
}
}
Main ()
{
RWList<A> alist;
A a1,a2;
...
a1.y("something");
a2.y("asdasdasa");
...
alist.insert(a1);
alist.inset(a2);
...
f(alist);
...
}
Please correct if anything wrong in my code.
It appears that begin and end function are not provided in the RWList
class. ( I tried AList.begin() and AList.end() )
Thanks,
Sangeetha.
I'm passing a RWList object of one complex data to function f(). In
the function f() i'm receiving in that list as reference. In the
function f(), i want to modify one member variable in all the nodes in
that input RWList. I've written following (dummy)code to do produce my
problem. The values modified in the function are not reflected in the
called function. I spend sometime not able to find/resolve the
problem...
class A{
public:
const RWString & x( return _x;}
const RWstring & y( return _y;}
void x(const RWStrng & value) { _x = value; }
void y(const RWStrng & value) { _y = value; }
private:
RWString _x;
RWString _y;
};
void f ( RWList<A>& alist) // receiving as reference of that list
{
RWListIter<A> AIter(alist);
while (AIter())
{
A &a = AIter.key(); // storing as reference
a.x("xxxxxxxxx");
}
}
Main ()
{
RWList<A> alist;
A a1,a2;
...
a1.y("something");
a2.y("asdasdasa");
...
alist.insert(a1);
alist.inset(a2);
...
f(alist);
...
}
Please correct if anything wrong in my code.
It appears that begin and end function are not provided in the RWList
class. ( I tried AList.begin() and AList.end() )
Thanks,
Sangeetha.