???IT???IT?? 2017-11-21 14:03 采纳率: 0%
浏览 805

关于重载运算符的友元函数的问题(VC)

#ifndef MYTIME3_H_
#define MYTIME3_H_
#include
using namespace std;
class Time
{
private:
int hours;
int minutes;
public:
Time();
Time(int h,int m=0);
void AddMin(int m);
void AddHr(int h);
void Reset(int h=0,int m=0);
Time operator+(const Time & t) const;
friend Time operator+(const Time & t1,const Time & t2);
friend Time operator-(const Time & t1,const Time & t2);
friend Time operator*(double n,const Time & t);
friend ostream & operator<<(ostream & os,const Time & t);
};
这是项目的头文件,编译时提示内部编译错误,是什么原因?

  • 写回答

2条回答

  • qq_35875027 2017-11-21 16:36
    关注

    友元必须先声明啊

    评论

报告相同问题?