24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 501  |  回复: 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的回帖

瞬间消失

铁虫 (小有名气)

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

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的回帖

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的回帖
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 化学0703 调剂 306分 一志愿211 +7 26要上岸 2026-03-28 7/350 2026-03-29 20:04 by 无际的草原
[考研] 070305高分子化学与物理 304分求调剂 +12 c297914 2026-03-28 12/600 2026-03-29 16:21 by Serene1974
[考研] 一志愿:西北大学,英一数一408-284分求调剂 +4 12.27 2026-03-27 4/200 2026-03-29 14:40 by zhshch
[考研] 309求调剂 +7 谁不是少年 2026-03-29 7/350 2026-03-29 13:17 by mumin1990
[考研] 375求调剂 +4 雨夏整夜 2026-03-29 4/200 2026-03-29 12:09 by 无际的草原
[考研] 343求调剂 +6 爱羁绊 2026-03-29 6/300 2026-03-29 12:00 by 无际的草原
[考研] 0856求调剂 +13 zhn03 2026-03-25 14/700 2026-03-29 08:13 by fmesaito
[考研] 283求调剂 +3 A child 2026-03-28 3/150 2026-03-28 15:41 by ms629
[考研] 312,生物学求调剂 +3 小译同学abc 2026-03-28 3/150 2026-03-28 15:32 by 落睿可思
[考研] 材料求调剂一志愿哈工大324 +7 闫旭东 2026-03-28 9/450 2026-03-28 08:51 by Xu de nuo
[考研] 一志愿 西北大学 总分282 英语一62 求调剂 +7 18419759900 2026-03-25 8/400 2026-03-27 16:38 by 18419759900
[考研] 07化学280分求调剂 +10 722865 2026-03-23 10/500 2026-03-27 15:51 by Plutoqq
[考博] 26申博 +3 加油冲啊! 2026-03-26 3/150 2026-03-27 15:38 by cls512
[考研] 351求调剂 +4 麦克阿磊 2026-03-24 4/200 2026-03-27 00:32 by wxiongid
[考研] 环境专硕324分求调剂推荐 +5 轩小宁—— 2026-03-26 5/250 2026-03-26 12:05 by i_cooler
[考研] 332求调剂 +6 032500 2026-03-25 6/300 2026-03-25 22:45 by 418490947
[考研] 0854电子信息求调剂 324 +4 Promise-jyl 2026-03-23 4/200 2026-03-25 11:36 by Sugarlight
[考研] 一志愿国科过程所081700,274求调剂 +3 三水研0水立方 2026-03-23 3/150 2026-03-23 23:11 by MajorWen
[考研] 336化工调剂 +4 王大坦1 2026-03-23 5/250 2026-03-23 18:32 by allen-yin
[考研] 接收2026硕士调剂(学硕+专硕) +4 allen-yin 2026-03-23 6/300 2026-03-23 15:04 by 汪!?!
信息提示
请填处理意见