| 查看: 456 | 回复: 4 | |||
| 当前主题已经存档。 | |||
[交流]
【求助】请教C++程序
|
|||
|
//st.h文件 class TDate{ public: void SetDate(int y,int m,int d); void ShowDate(); private: int year; int month; int day; }; class TStudent{ public: void SetStudent(char*sn,char*name,TDate bd,int cn); void Showstudent(); private: char sno[5]; char sname[10]; TDate birthday; int cno; }; //st.cpp文件 #include #include #include"st.h" void TDate::SetDate(int y,int m,int d) { year=y; month=m; day=d; }; void TDate::ShowDate() { cout< void TStudent::Setstudent (char*sn,char*name,TDate bd,int cn) { strcpy(sno,sn); strcpy(sname,sname); birthday=bd; birthday.SetDate(2006,12,16); cno=cn; } void TStudent::ShowStudent() { cout< cout< //eg7_2.cpp文件 #include #include"st.h" void main() { TDate b; TStudent s1; cout<<"访问类成员:\n"; cout< s1.ShowStudent(); } 我运行后提示fatal error C1083: Cannot open include file: 'st.h': No such file or directory 请高手指教!!多谢! [ Last edited by sunxiao on 2009-4-30 at 11:34 ] |
» 猜你喜欢
实验室接单子
已经有7人回复
假如你的研究生提出不合理要求
已经有11人回复
全日制(定向)博士
已经有5人回复
萌生出自己或许不适合搞科研的想法,现在跑or等等看?
已经有4人回复
Materials Today Chemistry审稿周期
已经有4人回复
参与限项
已经有3人回复
对氯苯硼酸纯化
已经有3人回复
求助:我三月中下旬出站,青基依托单位怎么办?
已经有12人回复
所感
已经有4人回复
要不要辞职读博?
已经有7人回复
woshilsh
荣誉版主 (职业作家)
- 应助: 43 (小学生)
- 贵宾: 10.33
- 金币: 21115.1
- 散金: 737
- 红花: 22
- 帖子: 3777
- 在线: 639.7小时
- 虫号: 293038
- 注册: 2006-11-04
- 专业: 计算机应用技术
- 管辖: 仿真模拟

2楼2009-01-14 18:29:46

3楼2009-01-26 13:16:18
dickli2008
银虫 (小有名气)
- 应助: 0 (幼儿园)
- 金币: 393.4
- 散金: 112
- 红花: 1
- 帖子: 236
- 在线: 114.5小时
- 虫号: 556129
- 注册: 2008-05-10
- 专业: 凝聚态物性 II :电子结构
★ ★ ★
sunxiao(金币+3,VIP+0):谢谢参与,欢迎常来交流 3-10 11:34
sunxiao(金币+3,VIP+0):谢谢参与,欢迎常来交流 3-10 11:34
|
完整的c++程序代码如下: //st.h文件 class TDate{ public: void SetDate(int y,int m,int d); void ShowDate(); private: int year; int month; int day; }; class TStudent{ public: void SetStudent(char*sn,char*name,TDate bd,int cn); void ShowStudent(); private: char sno[5]; char sname[10]; TDate birthday; int cno; }; //st.cpp文件 #include #include #include #include"st.h" using namespace std; void TDate::SetDate(int y,int m,int d) { year=y; month=m; day=d; }; void TDate::ShowDate() { cout< void TStudent::SetStudent (char*sn,char*name,TDate bd,int cn) { strcpy(sno,sn); strcpy(sname,name); birthday=bd; birthday.SetDate(2006,12,16); cno=cn; } void TStudent::ShowStudent() { cout< cout< //eg7_2.cpp文件 #include #include #include"st.h" using namespace std; void main() { TDate b; TStudent s1; b.SetDate(1987,3,19); cout<<"访问类成员:\n"; cout< s1.ShowStudent(); } 另外应该用构造函数constructor,析构函数destructor,这样比较好一些,而且可以用链表来表示学生的信息 |
4楼2009-03-10 11:14:51
dickli2008
银虫 (小有名气)
- 应助: 0 (幼儿园)
- 金币: 393.4
- 散金: 112
- 红花: 1
- 帖子: 236
- 在线: 114.5小时
- 虫号: 556129
- 注册: 2008-05-10
- 专业: 凝聚态物性 II :电子结构
5楼2009-03-10 11:16:44












回复此楼
,lz在//eg7_2.cpp文件 中加入iomanip.h头文件即可