FANTASTIC_STAY 2017-05-30 01:48 采纳率: 0%
浏览 728

程序报错求解决 输出到文件

调试环境:vc++6.0
报错:error C2679: binary '<<' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)

源代码:
// TO DO A LIST
#include
#include
#include
#include
#include
class Date //日期
{
int year,month,day;
public:
Date(int i=2000,int j=1 ,int k=1)
{
year=i;month=j;day=k;
}
void Dprint()
{
cout<<"截止日期:"<<year<<"."<<month<<"."<<day;
}
int get_year()
{ return year; }
int get_month()
{ return month; }
int get_day()
{ return day;}

};
class Time //时间
{
int hour,min;
public:
Time(int i=0,int j=0)
{
hour=i;min=j;
}
void Tprint()
{
cout<<"截止时间:"<<hour<<":"<<min;
}
int get_hour()
{ return hour; }
int get_min()
{ return min; }
};

class List:public Date,public Time //继承日期和时间
{
char List_name[100]; //任务标题
char List_dis[100]; //任务描述
public:
List (int a,int b,int c,int d,int e,char *name,char *dis):Date(a,b,c),Time(d,e)
{
strcpy(List_name,name);
strcpy(List_dis,dis);
}
List() //无参构造函数
{}

void Lprint()
{
    cout<<"任务标题:"<<List_name<<endl;
    cout<<"任务描述:"<<List_dis<<endl;
}
char* get_name()
{ return List_name;}
char* get_dis()
{ return List_dis;}

};
void menu() //菜单显示
{
cout<<"按1添加新任务"<<" "<<"按2查看现有任务"<<'\n'<<"按0退出";
}
void Add_task(List &A)
{

int a,b,c,d,e;
char name[100],dis[100];
cout<<"请输入任务名称";
cin>>name;
cout<<"请输入任务描述";
cin>>dis;
cout<<"请输入截止日期(格式为2000 1 1)";
cin>>a>>b>>c;
cout<<"请输入截止时间(格式为18 32)";
cin>>d>>e;
A=List(a,b,c,d,e,name,dis);

}
void Print(List A)
{

A.Dprint();cout< A.Tprint();cout A.Lprint();cout }
void main()
{
List *p;int m;
static int n=0; //记录有多少组任务
p=new List[100] ;
ofstream out;
for(int i=0;i {
menu();
cin>>m;
if(m==0||m==2) break;
if(m==1)
{
Add_task(p[i]);
cout<<"添加成功,按任意键继续"<<endl;
n++;
getch(); // 暂停程序运行,按任意键继续
system("cls"); //清空屏幕
}
}
if(m=2)
{
out.open("任务清单.txt");
for(i=0;i<n;i++)
{
out<<i+1<<".";
out<<"名称:"<<p[i].get_name<<endl;
out<<"描述:"<<p[i].get_dis<<endl;
out<<"日期:"<<p[i].get_year<<" "<<p[i].get_month<<" "<<p[i].get_day<<endl;
out<<"时间:"<<p[i].get_hour<<" "<<p[i].get_min;
out<<"---------------------------";
}
}
}

  • 写回答

1条回答 默认 最新

  • errors5835 2017-05-30 04:49
    关注

    那个错误是输出流没有重载

    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型