Copy std::map data to another map

前端 未结 2 1003
闹比i
闹比i 2021-02-01 18:48

I have a map that\'s defined like this

 struct A
 {
  int A;
  int B;
 };
 typedef map Amap;

Then I have Amap1 and I

2条回答
  •  死守一世寂寞
    2021-02-01 19:10

    Copying one map to another can be done with operator = or the copy constructor.

    E.g

    map mp1; 
    //fill mp1 with data
    map mp2(mp1); //mp2 is a copy of mp1 (via copy-construction)
    map mp3;
    mp3 = mp2; // mp3 is also a copy of mp2 (via copy-assignment)
    

提交回复
热议问题