//对象数组的创建与删除
#include<iostream.h>
#include<string.h>
class B
{
public:
B()
{cout<<"Default"<<endl;}
B(char *s,double n)
{
strcpy(name,s);
b=n;
cout<<"Constructor/n";
}
~B()
{cout<<"Destrutor"<<name<<endl;}
void getb(char *s,double &n)
{
strcpy(s,name);
n=b;
}
private:
char name[80];
double b;
};
void main()
{
B * pb;
double n;
char s[80];
pb=new B[3];
pb[0]=B("Wang",4.6);
pb[1]=B("Zhang",2.9);
pb[2]=B("Li",8.2);
for(int i=0;i<3;i++)
{
pb[i].getb(s,n);
cout<<s<<","<<n<<endl;
}
delete []pb;
}