24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 499  |  回复: 4
当前主题已经存档。

jianchaoyv

金虫 (小有名气)

[交流] 【求助】请教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<         birthday.ShowDate();
        cout< }
//eg7_2.cpp文件
#include
#include"st.h"
void main()
{
        TDate b;
        TStudent s1;
        cout<<"访问类成员:\n";
        cout<         s1.SetStudent("001","aaa",b,2);
        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 ]
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

woshilsh

荣誉版主 (职业作家)

优秀版主

★ ★
sunxiao(金币+2):多谢参与,呵呵 1-26 23:52
//eg7_2.cpp文件 应该包含 //st.cpp文件 这个吧,试试看
[center][url=http://www.91cool.net/][img]http://id.91cool.net/sign/?name=小木虫印&amp;amp;amp;say=各位版主辛苦了![/img][/url][/center]
2楼2009-01-14 18:29:46
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

瞬间消失

铁虫 (小有名气)

★ ★
sunxiao(金币+2):多谢参与,欢迎常来 1-26 23:52
楼上的汗一个,,lz在//eg7_2.cpp文件 中加入iomanip.h头文件即可
与大家共同进步
3楼2009-01-26 13:16:18
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dickli2008

银虫 (小有名气)

★ ★ ★
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<         birthday.ShowDate();
        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.SetStudent("001","aaa",b,2);
        s1.ShowStudent();
}
另外应该用构造函数constructor,析构函数destructor,这样比较好一些,而且可以用链表来表示学生的信息
4楼2009-03-10 11:14:51
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dickli2008

银虫 (小有名气)

建议好好的把think in c++好好看看,深入理解面向对象的概念(OOP)
5楼2009-03-10 11:16:44
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 jianchaoyv 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 081200-11408-276学硕求调剂 +6 崔wj 2026-03-26 6/300 2026-03-29 01:11 by hanserlol
[考研] 356求调剂 +3 gysy?s?a 2026-03-28 3/150 2026-03-29 00:33 by 544594351
[考研] 一志愿华北电力大学能动专硕,293,求调剂 +3 15537177284 2026-03-23 5/250 2026-03-28 16:11 by xxxsssccc
[考研] 312,生物学求调剂 +3 小译同学abc 2026-03-28 3/150 2026-03-28 15:32 by 落睿可思
[考研] 化学0703 调剂 306分 一志愿211 +4 26要上岸 2026-03-28 4/200 2026-03-28 15:30 by 1018329917
[考研] 0703本科郑州大学求调剂 +3 nhj_ 2026-03-25 3/150 2026-03-28 13:24 by Iveryant
[考研] 材料求调剂 一志愿哈工大总分298分,前三科223分 +5 dongfang59 2026-03-27 5/250 2026-03-28 04:53 by wxiongid
[考研] 330一志愿中国海洋大学 化学工程 085602 有读博意愿 求调剂 +3 wywy.. 2026-03-27 4/200 2026-03-28 03:32 by fmesaito
[考研] 275求调剂 +10 jjjjjjjjjjl 2026-03-27 10/500 2026-03-27 23:47 by barnett0632
[考研] 265求调剂11408 +3 刘小鹿lu 2026-03-27 3/150 2026-03-27 20:53 by nihaoar
[考研] 272求调剂 +7 脚滑的守法公民 2026-03-27 7/350 2026-03-27 17:23 by laoshidan
[考研] 283求调剂(080500) +4 A child 2026-03-27 4/200 2026-03-27 15:34 by XPU李庆
[论文投稿] Journal of Mechanical Science and Technology +3 Russ_ss 2026-03-25 5/250 2026-03-27 10:49 by 陆小果画大饼
[考研] 325求调剂 +5 李嘉图·S·路 2026-03-23 5/250 2026-03-27 00:42 by wxiongid
[考研] 340求调剂 +3 Amber00 2026-03-26 3/150 2026-03-26 18:57 by 不吃魚的貓
[考研] 347求调剂 +4 L when 2026-03-25 4/200 2026-03-25 13:37 by cocolv
[考研] 086003食品工程求调剂 +6 淼淼111 2026-03-24 6/300 2026-03-25 10:29 by 3Strings
[考研] 上海电力大学材料防护与新材料重点实验室招收调剂研究生(材料、化学、电化学,环境) +4 我爱学电池 2026-03-23 4/200 2026-03-25 00:59 by 1027_324
[有机交流] 有机合成求助 20+3 FENGSHUJEI 2026-03-23 5/250 2026-03-24 19:31 by 88817753
[考研] 335求调剂 +4 yuyu宇 2026-03-23 5/250 2026-03-23 23:49 by Txy@872106
信息提示
请填处理意见