为什么这个程序不执行就结束了?
#include <iostream>using namespace std;
class Book
{
private:
char bookname[20];
double price;
int number;
public:
Book(char *n,double p,int n2)
{
while(*n!=0)
{
int i=0;
bookname[i]=*n;
n++;
i++;
}
price=p;
number=n2;
}
void display();
int borrow();
int restore();
};
void Book::display()
{
cout<<price;
cout<<number;
}
int Book::borrow()
{
number-=1;
cout<<"当前存书数量";
return number;
}
int Book::restore()
{
number+=1;
cout<<"当前存书数量";
return number;
}
int main()
{
char str[10]="abc";
Book book1(str,10,40);
book1.display();
cout<<book1.borrow();
cout<<book1.restore();
}