24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 500  |  回复: 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 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 297求调剂 +11 田洪有 2026-03-26 11/550 2026-03-29 13:14 by peike
[考研] 343求调剂 +6 爱羁绊 2026-03-29 6/300 2026-03-29 12:00 by 无际的草原
[考研] 一志愿武汉理工,总分321,英一数二,求老师收留。 +10 nnnnnnn5 2026-03-25 10/500 2026-03-29 11:42 by longlotian
[考研] 279求调剂 +4 蝶舞轻绕 2026-03-29 4/200 2026-03-29 09:45 by laoshidan
[考研] 求调剂 +7 争取九点睡 2026-03-28 8/400 2026-03-28 21:07 by 争取九点睡
[考研] 一志愿北化085600材料专硕275|有文章专利|求调剂 +7 Micky11223 2026-03-25 7/350 2026-03-28 18:34 by 无际的草原
[考研] 一志愿厦门大学化学学硕307求调剂 +10 y7czhao 2026-03-26 10/500 2026-03-28 14:23 by 唐沐儿
[考研] 085600 286分 材料求调剂 +7 麻辣鱿鱼 2026-03-27 8/400 2026-03-28 12:17 by zllcz
[考研] 295求调剂 +5 1428151015 2026-03-27 6/300 2026-03-28 04:04 by fmesaito
[考研] 352分 化工与材料 +5 海纳百川Ly 2026-03-27 5/250 2026-03-28 03:39 by fmesaito
[考研] 265求调剂11408 +3 刘小鹿lu 2026-03-27 3/150 2026-03-27 20:53 by nihaoar
[考研] 287求调剂 +10 land xuxu 2026-03-26 10/500 2026-03-27 15:33 by 帕尔马拉特
[考研] 085601 材料工程 313分 求调剂 +5 Ong3 2026-03-27 5/250 2026-03-27 12:24 by goldfish51
[考研] 351求调剂 +4 麦克阿磊 2026-03-24 4/200 2026-03-27 00:32 by wxiongid
[考研] 化学工程085602 305分求调剂 +17 RichLi_ 2026-03-25 17/850 2026-03-26 19:44 by plmuchong
[考研] 一志愿河工大 081700 276求调剂 +4 地球绕着太阳转 2026-03-23 4/200 2026-03-26 14:27 by zzll406
[考研] 网络空间安全0839招调剂 +4 w320357296 2026-03-25 6/300 2026-03-25 17:59 by 255671
[考研] B区考研调剂 +4 yqdszhdap- 2026-03-22 5/250 2026-03-25 08:51 by baoball
[考研] 085404电子信息284分求调剂 +4 13659058978 2026-03-24 4/200 2026-03-24 12:15 by syl20081243
[考研] 一志愿重庆大学085700资源与环境,总分308求调剂 +7 墨墨漠 2026-03-23 8/400 2026-03-23 20:36 by Creta
信息提示
请填处理意见