Page 1 of 1

swap

Posted: Tue Feb 21, 2006 3:58 pm
by Artikali
i have two struct which contains string, integer and another types
for example

Code: Select all

struct{
char s[100];
int a,b,c,d[1000];
float f;
} one, two;
i swapped these manually, has anybody know how to swap these.
without changing their's pointers.
thanks

Posted: Tue Feb 21, 2006 4:30 pm
by sumankar
std::swap from <algorithm> might help, provided you've defined
[1] Copy ctor
[2] Assignment operator
for your struct.

thanks

Posted: Tue Feb 21, 2006 5:15 pm
by Artikali
thanks, it worked.