I have a class that has a template method in it. I inherit from the class and then implement the abstract methods. However, when I call the constructor it'll give an error. If I remove the () it won't give an error and run fine.
Code:
#include "BaseClass.hpp"
class someClassImp : public BaseClass{
public:
void func1(){
std::cout << "hey" << std::endl;
}
void func2(){
std::cout << "hey again" << std::endl;
}
};
int main(void) {
someClassImp printLines; //THIS WORKS FINE
//someClassImp printLines(); //WILL GIVE ERROR BELOW
printLines.templateMethod();
return 0;
}
error:
Code:
main.cpp: In function ‘int main(void)’:
error: request for member ‘templateMethod' in ‘printLines’, which is of non-class type ‘someClassImp ()()’
Why does that make a difference, and is this the correct way to implement a template method [without the () on the constructor]?
Thanks