Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <map>
- #include <sstream>
- #include <utility>
- using namespace std;
- //int Sqr(int x)
- //{
- // return x * x;
- //}
- //double Sqr(double x)
- //{
- // return x * x;
- //}
- // Шаблонный оператор умножения для пары любого типа
- template<typename First, typename Second>
- pair<First, Second> operator*(const pair<First, Second>& p1, const pair<First, Second>& p2)
- {
- First f = p1.first * p2.first;
- Second s = p1.second * p2.second;
- return make_pair(f, s);
- }
- template <typename T>
- T Sqr(T x)
- {
- return x * x;
- }
- int main()
- {
- /*cout << Sqr(2) << endl;
- cout << Sqr(2.5) << endl;*/
- auto p = make_pair(2.5, 3);
- auto res = Sqr(p);
- cout << res.first << endl;
- cout << res.second << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement