Something got wrong with class template syntax. Need your help. | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 2

Something got wrong with class template syntax. Need your help.

Can't figure out what I am missing. HEADER: #pragma once template <class T> class Pair { private: T first, second; public: Pair(T a, T b); T bigger(); ~Pair(); }; SOURCE: #include "stdafx.h" #include "Pair.h" template <class T> Pair::Pair(T a, T b) :first(a), secon(b) { } T Pair<T>::bigger() { return (first > second ? first : second); } Pair::~Pair() { } MAIN: #include "stdafx.h" #include <iostream> #include "Pair.h" using namespace std; int main() { Pair <int> obj(11,22); cout << obj.bigger() << endl; return 0; } Would appreciate any help.

28th Feb 2017, 1:59 PM
Arthur Fedotiev
Arthur Fedotiev - avatar
2 Antworten
+ 1
@Søren, as far as I know it is supposed to be there, but thank you for trying to help.
28th Feb 2017, 1:49 PM
Arthur Fedotiev
Arthur Fedotiev - avatar
0
You have put a semicolon at the end: https://gyazo.com/fa1d75680f1507cef1a2812ab1bae221 I'm new to c++, so sorry if i'm wrong.
28th Feb 2017, 1:41 PM
Søren