相关疑难解决方法(0)

C++:使用CRTP,派生类中定义的类在基类中不可访问

这是(简化的)基类:

template <class T>
class SharedObject
{
protected:
    QExplicitlySharedDataPointer <typename T::Data> d;
};
Run Code Online (Sandbox Code Playgroud)

以下是派生的:

class ThisWontCompile : public SharedObject <ThisWontCompile>
{
private:
    friend class SharedObject;
    struct Data : public QSharedData
    {
        int id;
    };
};
Run Code Online (Sandbox Code Playgroud)

是否有任何解决方法从SharedObject访问ThisWontCompile :: Data?使用基础对象中的派生对象究竟能做什么,究竟什么不能完成?

c++ qt templates crtp

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

标签 统计

c++ ×1

crtp ×1

qt ×1

templates ×1