加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 在模板化嵌套和继承类中未检测到的变量

发布时间:2020-12-16 09:41:12 所属栏目:百科 来源:网络整理
导读:我有一个像这样的嵌套和继承结构. template typename U,typename T,typename _Prd = equal_toT class Octree{...private : BBoxT,3,_Prd bounds ; void SplitNode() ; virtual bool isSplit () ;...};template typename U,typename _Prd = equal_toT class H
我有一个像这样的嵌套和继承结构.

template <typename U,typename T,typename _Prd = equal_to<T> >
class Octree
{
...
private :
    BBox<T,3,_Prd> bounds ;

    void SplitNode() ;
    virtual bool isSplit () ;
...
};


template <typename U,typename _Prd = equal_to<T> >
class Hull
{
    ...
    //nest the octree class here

    class OcHull: public Octree<U,T,_Prd>
    {
        bool isSplit () ;  
    };

    OcHull * GetOcHull() const ;

private:

    OcHull * hullstructure ;

};

当我想访问OcHull中的bounds变量时,编译器看不到它有这个变量.

template <typename U,typename _Prd>
bool Hull<U,_Prd>::OcHull::isSplit()
{
    assert(typeid(double) == typeid(T)) ;
    // for each possible view of currect cell

    for (size_t i = 0 ; i < camera_array.size() ; ++i)
    {
        //project centre of the cell

        // bounds is not detected. bound is meant to be inherited from BBox<T,_Prd> bounds ; above

        Vec<double,2> projectedP = camera_array[i].projectToCamPlane(bounds.centre) ; 

        ...


    }
}

错误是

Hull.hpp:84: error: ‘bounds’ was not declared in this scope

你能告诉我为什么它没有看到界限吗?

解决方法

你需要说这个> bounds或Octree< U,_Prd> :: bounds.在C中,当类模板继承自另一个类模板时,模板基类在第一次编译过程中未实例化,因此必须使用显式限定符访问继承的成员.

有关更详细的说明,请参见this answer.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读