How do i alter an element in the set for example how do i edit the 'm_a' member variable of a element in my set?

class CPerson
{
    public:
    int m_a;

    CPerson(int _a)
    {
        m_a = _a;
    }
}

set<CPerson*> myPersonSet;
..
...
set<CPerson*>::iterator it = myPersonSet.find( CPerson(20) );

// How do i change the value of the object i found in my list once i found it and it's referenced by my iterator?

Recommended Answers

All 2 Replies

You aren't showing enough code. What is the element that defines the set member? Is that being changed?

(*it)->m_a = 10;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.