免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1974 | 回复: 2

C++programming language书中的一个疑问 [复制链接]

论坛徽章:
0
发表于 2008-06-14 13:02 |显示全部楼层
temelate< class C > class Basic_ops { // basic operators on containers
bool operator ==( const C& )const ; // compare all elements
bool operator!=( const C& )const ;
/ / ...
};
template <class T > class Math_container : public Basic_ops < Math_container <T> > {
public :
size_t size()  const ;
T & operator [](size_t );
/ / ...
};

以上代码出自《the C++programming language》的第13。6节  请问这段代码是不是有问题? 是不是循环定义了Math_container   

[ 本帖最后由 vividone 于 2008-6-14 13:04 编辑 ]

论坛徽章:
0
发表于 2008-06-17 14:30 |显示全部楼层
这个怎么是循环定义?只是可能一次扫描无法分析出来。

论坛徽章:
0
发表于 2008-06-18 15:57 |显示全部楼层

回复 #1 vividone 的帖子

我贴一块csdn上人家给我的解答~  可能也有朋友有相同疑问~ 发在这里充实下FAQ

你先假设
Math_container <int>这样定义


那么
class Basic_ops
{
bool operator ==( const Math_container <int>& )const ; // compare all elements
bool operator!=( const Math_container <int>& )const ;
}

class Math_container <int>:public Basic_ops
{
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP