c++ 一道类的组合的题目,急求解答,谢谢了 25
#include<iostream>usingnamespacestd;classperiod{protected:intyear;intmonth;intday;pub...
#include<iostream>
using namespace std;
class period
{
protected:
int year;
int month;
int day;
public:
void input1()
{
cin>>year>>month>>day;
}
void output1()
{
cout<<year<<" "<<month<<" "<<day;
}
};
class time
{
protected:
int hour;
int minute;
int second;
public:
void input2()
{
cin>>hour>>minute>>second;
}
void output2()
{
cout<<hour<<" "<<minute<<" "<<second;
}
};
class arrangement
{
int n;
period m1;
time m2;
public:
void input3()
{
cin>>n;
m1.input1();
m2.input2();
}
void output3()
{
m1.output1();
m2.output2();
}
};
int main()
{
period p1;
time p2;
arrangement p3;
cout<<"请输入年 月 日"<<endl;
p1.input1();
cout<<"请输入时 分 秒"<<endl;
p2.input2();
cout<<"请输入事件安排的编号 年 月 日 时 分 秒"<<endl;
p3.input3();
cout<<"c++作业上传于";p1.output1();p2.output2();cout<<endl;
cout<<"c++作业截至于";p3.output3();cout<<endl;
return 0;
}
8.cpp:41: error: ‘time’ does not name a type
8.cpp: In member function ‘void arrangement::input3()’:
8.cpp:47: error: ‘m2’ was not declared in this scope
8.cpp: In member function ‘void arrangement::output3()’:
8.cpp:52: error: ‘m2’ was not declared in this scope
8.cpp: In function ‘int main()’:
8.cpp:59: error: expected ‘;’ before ‘p2’
8.cpp:59: warning: statement is a reference, not call, to function ‘time’
8.cpp:59: warning: statement has no effect
8.cpp:65: error: ‘p2’ was not declared in this scope 展开
using namespace std;
class period
{
protected:
int year;
int month;
int day;
public:
void input1()
{
cin>>year>>month>>day;
}
void output1()
{
cout<<year<<" "<<month<<" "<<day;
}
};
class time
{
protected:
int hour;
int minute;
int second;
public:
void input2()
{
cin>>hour>>minute>>second;
}
void output2()
{
cout<<hour<<" "<<minute<<" "<<second;
}
};
class arrangement
{
int n;
period m1;
time m2;
public:
void input3()
{
cin>>n;
m1.input1();
m2.input2();
}
void output3()
{
m1.output1();
m2.output2();
}
};
int main()
{
period p1;
time p2;
arrangement p3;
cout<<"请输入年 月 日"<<endl;
p1.input1();
cout<<"请输入时 分 秒"<<endl;
p2.input2();
cout<<"请输入事件安排的编号 年 月 日 时 分 秒"<<endl;
p3.input3();
cout<<"c++作业上传于";p1.output1();p2.output2();cout<<endl;
cout<<"c++作业截至于";p3.output3();cout<<endl;
return 0;
}
8.cpp:41: error: ‘time’ does not name a type
8.cpp: In member function ‘void arrangement::input3()’:
8.cpp:47: error: ‘m2’ was not declared in this scope
8.cpp: In member function ‘void arrangement::output3()’:
8.cpp:52: error: ‘m2’ was not declared in this scope
8.cpp: In function ‘int main()’:
8.cpp:59: error: expected ‘;’ before ‘p2’
8.cpp:59: warning: statement is a reference, not call, to function ‘time’
8.cpp:59: warning: statement has no effect
8.cpp:65: error: ‘p2’ was not declared in this scope 展开
5个回答
展开全部
8.cpp:41: error: ‘time’祥敏 没有定义
8.cpp: In member function ‘void arrangement::input3()’:
8.cpp:47: error: ‘m2’ 没声明
8.cpp: ‘void 成员中arrangement::output3()’:
8.cpp:52: error: ‘m2’ 没声明
8.cpp: 定义‘int main()’:
8.cpp:59 ‘p2’前没有 ‘;’
8.cpp:59: warning:声明不能CALL 或者function ‘time’
8.cpp:59: warning: 声明无效
8.cpp:65: error: ‘p2’ 没声明
CONST函数内部困档不能调用非CONST函数
一大堆函数没声明 要引用的又不引用 API又不declare
还有那个void成员都没有的都调用
重写吧 晕死 你那里汪宴乱复制人家的代码
8.cpp: In member function ‘void arrangement::input3()’:
8.cpp:47: error: ‘m2’ 没声明
8.cpp: ‘void 成员中arrangement::output3()’:
8.cpp:52: error: ‘m2’ 没声明
8.cpp: 定义‘int main()’:
8.cpp:59 ‘p2’前没有 ‘;’
8.cpp:59: warning:声明不能CALL 或者function ‘time’
8.cpp:59: warning: 声明无效
8.cpp:65: error: ‘p2’ 没声明
CONST函数内部困档不能调用非CONST函数
一大堆函数没声明 要引用的又不引用 API又不declare
还有那个void成员都没有的都调用
重写吧 晕死 你那里汪宴乱复制人家的代码
展开全部
编译了一帆衫下,没事啊,代码没问题,你看看你编译的文件是不是该文件的,有时候姿厅打迹轿隐开了别的代码就编译,根本没拷进工程里
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
先在源程序中标出行数来吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
朋友,你用的是什么编译器?用G++试试,肯定能运行
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询