Hello,
I'm trying to make a custom set that will only keep the highest n entries based on a custom comparator (if there is already a way of doing this with the STL let me know!). Anyway, it works on Windows with Visual Studio 2010, but not on Linux with GCC 4.1.2. My code is as follows:
When this is compiled, the following output is generated:
test.cpp: In member function 'bool MySet<T>::insert(T)':
test.cpp:23: error: expected `;' before 'it'
test.cpp:25: error: 'it' was not declared in this scope
test.cpp: In function 'int main(int, char**)':
test.cpp:45: error: missing template arguments before 'test'
test.cpp:45: error: expected `;' before 'test'
test.cpp:47: error: 'test' was not declared in this scope
If the template<class T> is replaced with typedefdouble T; it compiles fine. Any ideas?
For the second error (in main function)
This is incorrect: MySet test(3,test_comp);
should be MySet<some_type_in_here> test(3,test_comp); as MySet is a template class.