consider the following code:
template<class T>
class Base {
public:
void doSomething(){}
};
template<class T>
class Derived : public Base<T> {
public:
void doMore() {
doSomething(); //Affected line
}
};
In the line commented with "affected line" g++ (4.7) says:
test.cc:11:16: error: there are no arguments to ‘doSomething’ that depend on a template parameter, so a declaration of ‘doSomething’ must be available [-fpermissive]
Now I am wondering:
- If the template parameter T would not be there, this error would not occure. What is the difference?
- g++ obviously is able to resolve this problem (if I add -fpermissive it compiles fine). I am assuming that g++ tries to make the best experience for me as the "user" (programmer). What are the advantages for me when g++ does not accept this code?
Thanks! Nathan