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
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试