+ 1

Hey is it nrccessary to tell the compiler what datatypes are used? I thought it calculates the datatype automatically?

#include <iostream> using namespace std; template <class T> class Pair { private: T first, second; public: Pair (T a, T b): first(a), second(b) { } T bigger(); }; template <class T> T Pair<T>::bigger() { return (first>second ? first : second); } int main() { Pair <int> obj(11, 22); cout << obj.bigger(); return 0; }

27th Dec 2018, 11:08 PM
Daniel
1 Respuesta
0
Yes you should tell it. Btw your code has run successfully.
28th Dec 2018, 12:11 AM
GiveAway
GiveAway - avatar