24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 496  |  回复: 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 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 070300化学354求调剂 +4 101次希望 2026-03-28 4/200 2026-03-29 06:19 by 松花缸1201
[考研] 330分求调剂 +3 qzenlc 2026-03-29 3/150 2026-03-29 06:18 by 544594351
[考研] 086000生物与医药调剂 +3 Feisty。 2026-03-28 7/350 2026-03-29 00:41 by 544594351
[考研] 一志愿北京工业大学,324分求调剂 +4 零八# 2026-03-28 4/200 2026-03-28 15:01 by 17865157980
[考研] 311求调剂 +4 冬十三 2026-03-24 4/200 2026-03-28 13:17 by 唐沐儿
[考研] 085405 考的11408求各位老师带走 +3 Qiu学ing 2026-03-28 3/150 2026-03-28 09:19 by 乐呵呵的追梦人
[考研] 328求调剂 +7 嗯滴的基本都 2026-03-27 7/350 2026-03-28 04:19 by fmesaito
[考研] 一志愿南师大0703化学 275求调剂 +4 Ripcord上岸 2026-03-27 4/200 2026-03-27 17:00 by zhyzzh
[考研] 283求调剂(080500) +4 A child 2026-03-27 4/200 2026-03-27 15:34 by XPU李庆
[考研] 求调剂,一志愿 南京航空航天大学大学 ,080500材料科学与工程学硕 +4 @taotao 2026-03-26 5/250 2026-03-27 08:10 by hypershenger
[考研] 304材料求调剂 +4 钟llll 2026-03-26 4/200 2026-03-27 03:42 by wxiongid
[考研] 085602 289分求调剂 +8 WWW西西弗斯 2026-03-24 8/400 2026-03-26 16:33 by 不吃魚的貓
[考研] 打过很多竞赛,085406控制工程300分,求调剂 +3 askeladz 2026-03-26 3/150 2026-03-26 09:08 by 给你你注意休息
[考研] 290分调剂求助 +3 吉祥止止陈 2026-03-25 3/150 2026-03-25 19:58 by barlinike
[考研] 26考研-291分-厦门大学(085601)-柔性电子学院材料工程专业求调剂 +3 min3 2026-03-24 4/200 2026-03-25 18:22 by xcjcqu
[考研] 0854AI CV方向招收调剂 +4 章小鱼567 2026-03-23 4/200 2026-03-25 17:04 by CoderLoser
[考研] 0854人工智能方向招收调剂 +4 章小鱼567 2026-03-24 4/200 2026-03-25 13:29 by 2177681040
[考研] 一志愿北化315 求调剂 +3 akrrain 2026-03-24 3/150 2026-03-24 19:35 by 了了了了。。
[考研] 材料专硕找调剂 +5 哈哈哈吼吼吼哈 2026-03-23 5/250 2026-03-24 19:07 by 了了了了。。
[考研] 求调剂一志愿武汉理工大学材料工程(085601) +5 WW.' 2026-03-23 7/350 2026-03-24 14:50 by sprinining
信息提示
请填处理意见