Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int f() { return 2;}
- double f() { return 2.7;}
- #include <cstdio>
- template <typename typed> typed f() { return 2.7; }
- int main(void) { return !printf("%d %f", f<int>(), f<double>()); }
- #include <cstdio>
- //template <typename typed> typed f() { return f<void>(); }
- //template <typename typed> typed f() { return f<void>(); return f<int>(); }
- template <typename typed> typed f();
- template <> int f() { return 2; }
- template <> double f() { return 2.7; }
- int main(void) { return !printf("%d %f", f<int>(), f<double>()); }
- template<typename T> T f();
- template<> int f() { return 2; }
- template<> double f() { return 2.7; }
- int x1 = f<int>();
- double y1 = f<double>();
- struct F {
- F() {}
- template<typename T> operator T() { return f<T>(); }
- };
- int x2 = F();
- double y2 = F();
- auto a = F();
- #include <iostream>
- using namespace std;
- namespace _double
- {
- double f()
- {
- return 2.6;
- }
- }
- namespace _int
- {
- int f()
- {
- return 2;
- }
- }
- int main()
- {
- cout << _double::f() << " " << _int::f() << endl;
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement