| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 563 人关注过本帖
标题:编程中遇到的问题
只看楼主 加入收藏
Jewgle
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2005-10-12
收藏
 问题点数:0 回复次数:3 
编程中遇到的问题

正在学c++,试着写了个小型的图书馆管理系统,写了一部分就遇到个问题,大家帮帮忙!
只需看下红色部分就可以了,是关于一个赋值的问题:
#include<iostream.h>
#include<afx.h>
class BookCard //图书卡类
{public:
int m_bCount; //书的数量
CString m_bKind; //书的种类
CString m_bName; //书名
CString m_bNum; //书的编号
CString m_bAuthorName; //作者姓名
void BookCardRegister(CString Kind,CString Name,CString AuthorName,
CString Num,int Count); //新书入库
};
class Validity //借书证类
{public:
CString m_vName; //姓名
CString m_vSex; //性别
CString m_vNum; //学号
CString m_vDepartment; //所在学院
void ValidityRegister(CString Name,CString Sex,CString Num,CString Department);//借书证入库
};
class LendRecord:public BookCard,public Validity//
借书记录类
{
CTime m_lLendTime; //借出时间
CTime m_lReturnTime; //归还时间
public:
void LendStatistics(CString BookName,CString BookNum,CString StudentName,CString sex,
CString StudentNum,CTime LendTime,CTime ReturnTime);//借书登记
int ReturnStatistics(CString BookName,CString BookNum,CString StudentName,CString sex,
CString StudentNum,CTime LendTime,CTime ReturnTime);//还书处理
};
void BookCard::BookCardRegister(CString Kind,CString Name,CString Num,CString AuthorName,
int Count)

{
m_bKind=Kind;
m_bName=Name;
m_bNum=Num;
m_bAuthorName=AuthorName;
m_bCount=0;
m_bCount=m_bCount+Count;
}
void Validity::ValidityRegister(CString Name,CString Sex,CString Num,CString Department)
{
m_vName=Name;
m_vSex=Sex;
m_vNum=Num;
m_vDepartment=Department;
}
void LendRecord::LendStatistics(CString BookName,CString BookNum,CString StudentName,CString Sex,
CString StudentNum,CTime LendTime,CTime ReturnTime)
{
m_bName=BookName;
m_bNum=BookNum;
m_vName=StudentName;
m_vSex=Sex;
m_vNum=StudentNum;
m_lLendTime=LendTime;
m_lReturnTime=ReturnTime;
}
int LendRecord::ReturnStatistics(CString BookName,CString BookNum,CString StudentName,CString Sex,
CString StudentNum,CTime LendTime,CTime ReturnTime)
{
int overdue=0;
CTimeSpan interval;
m_bName=BookName;
m_bNum=BookNum;
m_vName=StudentName;
m_vSex=Sex;
m_vNum=StudentNum;
m_lLendTime=LendTime;
m_lReturnTime=ReturnTime;
interval=ReturnTime-LendTime;
overdue=(interval>CTimeSpan(180,0,0,0)?1:0);
return overdue;
}
void main()
{
BookCard Book;
Validity Docu;
LendRecord Record;
CTime LendTime,ReturnTime;
LendTime=CTime(2005,9,1,0,0,0);
ReturnTime+=CTimeSpan(180,0,0,0);
Book.BookCardRegister("计算机","c语言程序设计","谭浩强","050201",150);
Docu.ValidityRegister("张三","男","026210101","计算机信息工程学院");
Record.LendStatistics("c语言程序设计","050201","张三","男","026210101",LendTime,ReturnTime);
Record.ReturnStatistics("c语言程序设计","050201","张三","男","026210101",LendTime,ReturnTime);
cout<<"馆内现有"<<Book.m_bCount<<"本"<<"<<"<<Book.m_bName<<">>"<<"教材!"<<endl;
cout<<LendTime.Format("%B%d,%Y")<<"借出一本"<<endl;
cout<<"借阅者:"<<endl;
cout<<"Department:\t";
cout<<Record.m_vDepartment<<endl;
cout<<"Name:\t";
cout<<Record.m_vName<<endl;
cout<<"Sex:\t";
cout<<Record.m_vSex<<endl;
cout<<"Num:\t";
cout<<Record.m_vNum<<endl;
}
跟踪调试过程中,函数ValidityRegister中的m_vDepartment=Department顺利执行,但m_vDepartment的输出结果确是空的!
m_vDepartment,_vName,m_vSex,m_vNum等都是公有继承Validity类的,惟独m_vDepartment输出的结果是空的...
大家大家指点指点,谢啦!

搜索更多相关主题的帖子: public include 
2005-11-30 15:40
Jewgle
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2005-10-12
收藏
得分:0 

怎么没人理我呢?

2005-12-02 11:27
lll1231230
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-9-6
收藏
得分:0 
我理你一下吧
可是我是个菜鸟 不会
2005-12-02 14:13
Jewgle
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2005-10-12
收藏
得分:0 


还是谢谢你了
还没成为孤家寡人

2005-12-03 14:38
快速回复:编程中遇到的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019840 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved