is there a built in function to deal with numbers similar to how the swap member function (first.swap(second);) deals with strings? thanks
GPXtC02
0
Light Poster
Recommended Answers
Jump to Postthat is a template and works with strings as well as integers.
int main() { string a = "Hello"; string b = "World"; swap(a,b); cout << a << " " << b << "\n"; return 0; }
Jump to Post>is there a built in function to deal with numbers similar to how the swap member function
Yes, include <algorithm> and you can use the std::swap template function as AD has shown.
Jump to PostNarue its a part of utility.h in VS2008 and in Utility.h and xstring on VS2005.
Jump to Post>Narue its a part of utility.h in VS2008 and in Utility.h and xstring on VS2005.
That's nice. And your point is?
All 13 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Narue
5,707
Bad Cop
Team Colleague
Laiq Ahmed
42
Junior Poster
Narue
5,707
Bad Cop
Team Colleague
GPXtC02
0
Light Poster
Narue
5,707
Bad Cop
Team Colleague
GPXtC02
0
Light Poster
GPXtC02
0
Light Poster
Narue
5,707
Bad Cop
Team Colleague
GPXtC02
0
Light Poster
Narue
5,707
Bad Cop
Team Colleague
GPXtC02
0
Light Poster
GPXtC02
0
Light Poster
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.