0
The code shown below in the description runs here when I try it, but when I wrote it on code blocks it gave me 5 errors.. 1. expected imitializer before '<' token. (line 19). 2. reference to 'pair' is ambiguous. (line 26). 3. expected primary-expression before double. (line 26). 4. expected ';' before 'double'. (line 26). 5. 'obj' was not declared in this scope. (line 27). Any help please?
#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 <double> obj(23.43, 5.68); cout << obj.bigger(); return 0; }
5 Antworten
+ 2
Go to Toolbar -> Settings -> Compiler
In the "Selected compiler" drop-down menu, make sure "GNU GCC Compiler" is selected
Below that, select the "compiler settings" tab and then the "compiler flags" tab underneath
In the list below, make sure the box for "Have g++ follow the C++11 ISO C++ language standard [-std=c++11]" is checked
Click OK to save
from stack overflow
+ 1
did you activated the new c++11 language features, -std=c++11
+ 1
you are welcome :)
0
no I did not, how do I do this?
0
thank you so much Mr Mazen ☺