Jump to content

Шаблоны С++ (DEV C++)


Recommended Posts

всем доброго времени суток, подскажите, пож, почему при вызове функции происходит ошибка,

"...call of overloaded `swap(int&, int&)' is ambiguous", (что-то вроде: вызов перегруженной функции двусмысленный)

#include <iostream>using namespace std;template <typename T>void swap(T& a, T& b);int main(){int i = 10;int j = 20;cout << "i, j = " << i << ", " << j << ".\n";cout << "using int swap:\n";swap(i, j);cout << "now i, j = " << i << ", " << j << ".\n";double x = 24.5;double y = 81.7;cout << "x, y = " << x << ", " << y << ".\n";cout << "using double swap:\n";swap(x, y);cout << "now x, y = " << x << ", " << y << ".\n";system("pause");return 0;}template <typename T>void swap(T& a, T& b){ T temp; temp = a; a = b; b = a;}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...