typedef有关问题,请各位多多指教
#include<iostream>
using namespace std;
class Book
{
private:
static int count;
public:
Book(char *tile)
{
cout<<"售出的图书:"<<tile<<endl;
count++;
}
static int Getcount()
{
return count;
}
};
int Book::count = 0;
int main()
{
typedef char String[100];
String titles[]={"JAve1","Jave2","Jave3"};//当把String titles[]换成String *titles会出错
for(int i = 0;i<3;i++)
{ //如何判断titles[i]判断为空,从而创建内存空间
new Book(titles[i]);
}
cout<<Book::Getcount()<<endl;
return 0;
}