Chinaunix首页 | 论坛 | 博客
  • 博客访问: 576047
  • 博文数量: 79
  • 博客积分: 2513
  • 博客等级: 少校
  • 技术积分: 806
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-04 18:46
文章分类

全部博文(79)

文章存档

2014年(1)

2010年(5)

2009年(8)

2008年(11)

2007年(41)

2006年(13)

我的朋友

分类: C/C++

2007-12-23 21:57:58

今天写一个测试程序的时候,遇到一个新的问题,代码示例如下,在 G++ 4.x 下编译出错:

template <typename Compare>
class test_base
{
protected:
  Compare comp;
};

template <typename Iter, typename Compare>
class test: public test_base<Compare>
{
public:
  void foo(Iter first, Iter last)
  {
    std::sort(first, last, comp); // 编译错误: comp 不可见

  }
};


最后解决的办法是在 test 里加一句 using test_base::comp;

这个就很奇怪了。
阅读(1538) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~