0

First - I'm know this is really noob question - but hey - we all start with being noobs, aren't we?... So, to the Q: I'm want to use inherited template classes, and I've having hard time dealing with this stuff. This is the code, written in Microsoft Visual Studio Professional 2012:

template <class T>
class A
{
protected:
    int f(){return 0};
};

template <class T>
class B : public A<T>
{
protected:
    int f2()
    {
        return this->;
    }
};

Thing is, in the auto-complete option, I used to see all B 'variables', which are actual B variables along A variables. But when I use template - I can see only class B variables, when writing down "this->". (Needless to say - when I delete the template declarations - it worked out just fine, and "this->" will give me both f() and f2() options) Is there's anything I'm doing wrong?

4

1 回答 1

0

我认为您的问题与此问题重复:

模板:父类成员变量在继承类中不可见

UncleBens的第一个答案总结得很好。

[...]模板类的模板父级在首先检查模板的编译过程中未实例化。[...]

他还提供了更多信息和进一步阅读的良好链接。

于 2013-07-16T12:42:31.817 回答