template inheritance c++

后端 未结 4 1269
天涯浪人
天涯浪人 2020-12-08 16:28

i am a new programmer in c++. and i am using templates for the first time.

i have an abstract class and another class extending it. but all the protected members of

4条回答
  •  春和景丽
    2020-12-08 16:55

    For a name to be looked up in a dependent base class, two conditions need to be satisfied

    • It's necessary that the lookup is not unqualified
    • It's necessary that the name is dependent

    These rules as stated in C++03 are different from the rules stated by unrevised C++98, where satisfying the second bullet (making a name dependent) was sufficient for finding names declared in dependent base classes.

    A dependent name is looked up at instantiation time and a lookup other than unqualified lookup will not ignore dependent base classes. Both of these conditions need to be satisfied to find a name declared in a dependent base class, neither of them alone is sufficient. To satisfy both conditions you can use various constructs

    this->p
    class1::p
    

    Both names p are dependent and the first version uses class member access lookup and the second version uses qualified name lookup.

提交回复
热议问题