小编lui*_*mis的帖子

模板继承:没有依赖于模板参数的参数

编译以下代码时遇到此错误.在做了一些研究并在不同情况下阅读类似的错误之后,我想出了我需要的解决方案.但我没有完全理解错误和修复的不正当理由.

template <typename T>
class TestA {
    int a;
    T temp;

protected:
    int b; 

public: 
    int c;

    TestA(T te): a{10}, b{20}, c{30}, temp{te} {}

    int geta(){ return a; }
    int getb(){ return b; }
    int getc(){ return c; }
};

template <typename T>
class TestB {
    int atb;
    T tempb;

protected:
    int btb; 

public: 
    int ctb;

    TestB(T te) atb{10}, btb{20}, ctb{30}, tempb{te} {}
};

template <typename T>
class TestInh : public TestA<T>, public TestB<T> {
    int aa;
    T temptemp;

protected: …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance templates

1
推荐指数
1
解决办法
2911
查看次数

标签 统计

c++ ×1

inheritance ×1

templates ×1