标题:这个类..那错了????!
取消只看楼主
wandison
Rank: 1
等 级:新手上路
帖 子:50
专家分:4
注 册:2006-11-7
 问题点数:0 回复次数:1 
这个类..那错了????!

#include<iostream.h>
#define N 20
#include<string.h>
class object
{
char name[N];
int no;
public:
object(char na[N],int num);

};
class Book: public object
{
char author[20];
public:

Book(char na[N],int num,char zuozhe[N]);

Book();
void setBook(char na[N],int num,char zuozhe[N]);

};
object::object(char na[N],int num)
{
strcpy(name,na);
no=num;
}
Book::Book(char na[N],int num,char zuozhe[N]):object(na[N],num)
{
strcpy(author,zuozhe);
}


class Reader:public object
{
public:
Reader(char na[N],int num):object(na[N],num)
{
cout<<"读者: "<<name[N]<<"("<<no<<")"<<endl;
cout<<"所借图书:"<<endl;
}

Reader();
void setReader(char na[N],int num)
{
strcpy(object::name,na);object::no=num;
cout<<"读者: "<<object::name<<"("<<object::no<<")"<<endl;
cout<<"所借图书:"<<endl;
}

void rentBook(Book &a)
{
static int n=1;
cout<<" "<<n<<". ";
n++;
cout<<a.name<<"("<<a.no<<")"<<endl;
}
};


void main()
{
Book b1("C语言", 1,"潭浩强"),b2("数据结构", 2,"严蔚敏"),b3,b4,b5;
Reader r1("王华",1),r2;
b3.setBook("VB程序设计",3, "成功");
b4.setBook("数据库原理",4, "王瑟");
b5.setBook("计算机导学",5, "张仁");
r2.setReader("李明",2);
r1.rentBook(b1);
r1.rentBook(b3);
r2.rentBook(b2);
r2.rentBook(b4);
r2.rentBook(b5);
}

搜索更多相关主题的帖子: class include 
2007-05-13 21:27
wandison
Rank: 1
等 级:新手上路
帖 子:50
专家分:4
注 册:2006-11-7
得分:0 
就是不能通过啊,你帮我调试一下;谢谢!

2007-05-13 23:26



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-139133-1-1.html




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

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