相关疑难解决方法(0)

接口和协方差问题

我有一个特定的类来存储一段数据,它实现了一个接口:

template<typename T>
class MyContainer : public Container<T> {
    class Something : public IInterface {
    public:
        // implement *, ->, and ++ here but how?
    private:
        T x;
    };

    // implement begin and end here, but how?

private:
    Something* data; // data holds the array of Somethings so that references to them can be returned from begin() and end() to items in this array so the interface will work, but this makes the problem described below
};
Run Code Online (Sandbox Code Playgroud)

而且我有一系列Something的. …

c++ iterator interface covariance

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

标签 统计

c++ ×1

covariance ×1

interface ×1

iterator ×1