Click here to Skip to main content
15,907,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CSS
hi,

i want to use the CMap of CMap for storing some data

e.g.

class A{
    CMap<CString, LPCSTR,B,B&> mapB;

    CString name;
};

class B{
    CString name;
};

and now i want use the
CMap<CString, LPCSTR,A,A&> mapA;
on compiling here it was giving the error like
"'operator =' function is unavailable"
so in class A i added operator
void operator=(const A& ao_obj){
//what should i write here
}

then it compiled with 0 errors
and then i added data in map A

CString key="1";
A aobj;
aobj.name="SomeName";
mapA[key] = aobj;

Now at the time of retrieving this A object
it is not storing the value in the object
means
CString k1="1";
A objA;
mapA.Lookup(k1,objA);

so here it should store the value in objA
but it is not doing this
it is happening because of operator=
what should i write in 'operator=' function?
Posted

i found the solution,

in operator= function,

void operator=(const A& ao_obj){

//here, we should set the members of the class A from the passed 'ao_obj'
name = ao_obj.name;
}

by doing this, on look up it is storing the value for the respective key.

anyways thanks to all of you
 
Share this answer
 
v2
its ok
u got the answer correct.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900