怎样才能输出类中 缺省的数据?
#include<iostream>using namespace std;
const int SIZE=80;
class Stock
{
public:
/* Stock()
{
strcpy(stockcode," ");
}*///这个函数有什么用呢?
Stock(char code[],double q=1000,double p=8.96)
{
strcpy(stockcode,code);
quan=q;
price=p;
}
void print()
{
cout<<this->stockcode;
cout<<" "<<this->quan<<" "<<this->price<<endl;
}
private:
char stockcode[SIZE];
double quan;
double price;
};
int main()
{
// Stock z();//怎么才能使其输出所有的原始数据呢?
// z.print();
Stock x("60003",56,23);
x.print();
Stock y("2232");
y.print();
return 0;
}