Click here to Skip to main content
15,885,887 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an CArray<int,int> a, and CArray<int,int> b;
I want to copy b in the beginning of a, so I can't do a.Append(b);

What I have tried:

I tried to use the function "copy" but with copy I copy a vector in an other and the second is deleted
Posted
Updated 29-Sep-21 7:29am
Comments
jeron1 29-Sep-21 12:38pm    
Something like?

a.InsertAt(0, &b); // inserts the contents of b starting at the beginning of a

If you want the contents of b followed by the contents of a then:
C++
b.Append(a);
a.Copy(b);

will do it.
 
Share this answer
 
v2
Comments
CPallini 29-Sep-21 13:26pm    
Indeed.
5.
Richard MacCutchan 30-Sep-21 3:59am    
Thanks.
HAve also a look at the InsertAt method: CArray Class | Microsoft Docs[^].

By the way, C++ standard library containers (e.g. std::vector) are usually better than corresponding MFC ones.
 
Share this answer
 
Comments
Rick York 29-Sep-21 16:05pm    
Definitely! I still use MFC and never, ever use its containers.

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