swap

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
Artikali
Learning poster
Posts: 68
Joined: Wed Sep 21, 2005 5:27 pm

swap

Post by Artikali » Tue Feb 21, 2006 3:58 pm

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

sumankar
A great helper
Posts: 286
Joined: Tue Mar 25, 2003 8:36 am
Location: calcutta
Contact:

Post by sumankar » Tue Feb 21, 2006 4:30 pm

std::swap from <algorithm> might help, provided you've defined
[1] Copy ctor
[2] Assignment operator
for your struct.

Artikali
Learning poster
Posts: 68
Joined: Wed Sep 21, 2005 5:27 pm

thanks

Post by Artikali » Tue Feb 21, 2006 5:15 pm

thanks, it worked.

Post Reply

Return to “C++”