3

I am trying to compile this:

template <class L>
class A
{
        virtual int doIt() = 0;
};

template <class L>
class B : public A<L>
{
        int doItAgain() { return doIt(); }
};

int main()
{
}

and getting the error:

3.cc: In member function ‘int B<L>::doItAgain()’:
3.cc:11:32: error: there are no arguments to ‘doIt’ that depend on a template parameter, so a declaration of ‘doIt’ must be available [-fpermissive]
  int doItAgain() { return doIt(); }
                                ^
3.cc:11:32: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)

with g++. clang gives an error as well:

3.cc:11:27: error: use of undeclared identifier 'doIt'
        int doItAgain() { return doIt(); }
                                 ^
1 error generated.
kloop
  • 4,537
  • 13
  • 42
  • 66
  • 1
    `this->doIt();` ... there's a duplicate of this – Praetorian Dec 15 '16 at 21:49
  • ah ha. I found this http://blog.llvm.org/2009/12/dreaded-two-phase-name-lookup.html (just for the record), but it doesn't seem to give a solution. your solution works perfectly. thanks. – kloop Dec 15 '16 at 21:52

0 Answers0