编译时奇怪的问题 貌似二义性了 但是在哪儿? 求解
#include <cstdlib>#include <iostream>
using namespace std;
class Base
{
private:
int number;
char name[10];
public:
Base(int a,char *n)
{
number = a;
strcpy(name,n);
}
void show()
{
cout<<number<<'\t'<<name;
}
};
class Book:public Base
{
private:
char author[10];
public:
Book(int no,char *book, char *aut):Base(no,book)
{
strcpy(author,aut);
}
void show()
{
Base::show();
cout<<'\t'<<author<<endl;
}
};
class Reader:public Base
{
private:
int amount;
Book books[10];
public:
Reader(int no,char *reader):Base(no,reader)
{
amount=0;
}
void show(void)
{
cout<<"reader ";
Base::show();
cout<<endl;
cout<<" borrow:"<<endl;
for(int i=0; i<amount; i++)
{
cout<<" "<<i+1<<":";
books[i].show();
}
}
void borrow(Book &b)
{
books[amount++]=b;
}
};
int main(int argc, char *argv[])
{
Book book[]={Book(1,"hello","chen"),
Book(2,"hi","chen"),
Book(3,"fine","chen"),
Book(4,"bye","chen")};
Reader reader[]={ Reader(1,"zhang"),
Reader(2,"wang")};
reader[0].borrow(book[1]);
reader[1].borrow(book[4]);
reader[0].show();
reader[1].show();
system("PAUSE");
return EXIT_SUCCESS;
}