随笔 - 2, 文章 - 0, 评论 - 3, 引用 - 0
数据加载中……

cannot access private member

class Time{
//public:
  int hour, minute, second;
public:
  void set(int h, int m, int s){ hour=h, minute=m, second=s; }
  friend Time& operator++(Time& a);
  friend Time operator++(Time& a, int);
  friend ostream& operator<<(ostream& o, const Time& t);
};
使用自定义类时,编译提示错误:cannot access private member declared in class 'Time'
开始以为类定义时默认是私有变量,加上public,似乎可以解决问题
其实还是没有声明类引起的。

posted on 2009-01-15 15:36 Robbin 阅读(1492) 评论(0)  编辑 收藏 引用 所属分类: C++BUG


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理