[ create a new paste ] login | about

Link: http://codepad.org/axjCAZyL    [ raw code | output | fork ]

C++, pasted on Oct 27:
template<typename T1, typename T2>
class Pair
{
     public:
         T1 First;
         T2 Second;
         Pair(const T1 &First, const T2 &Second) : First(First), Second(Second) { }
};

template<typename T1, typename T2>
Pair<T1, T2> MakePair(const T1 &First, const T2 &Second)
{
    return Pair<T1, T2>(First, Second);
}
template<typename T1, typename T2>
Pair<T1, T2> MakePair(const T2 &Second, const T1 &First)
{
    return Pair<T1, T2>(First, Second);
}

int main() {

    Pair<int,char> a = MakePair(1, '0');
}


Output:
1
2
3
In function 'int main()':
Line 23: error: call of overloaded 'MakePair(int, char)' is ambiguous
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: