class cellPair
{
  public:
      vector<int> pair;
	  int  size;
	  cellPair(const int& a) {   pair.push_back(a); size=static_cast<int>( pair.size() ); }

   };
 int main()
{
   map<int, cellPair> aMap;
   
  aMap[1]=cellPair(3);
  aMap[1]=cellPair(2);
  
}
  I think the aMap.second.size should ==2, but it still have 1 value, the second value did not push back to the pair.
   Could you please give me some suggestions?

every call of cellPair() is creating an object of cellPair, so cellPair(3) and cellPair(2) are two different objects each has one vector in it with 3 and 2 respectively.

aMap[1]=cellPair(3); // first object of cellPair
  aMap[1]=cellPair(2); // second object of cellPair, no relation with the first object
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.