构造函数放外面错误原因
程序代码:#include<iostream>
using namespace std;
const int size=100;
class Stock{
public:
Stock(){
strcpy(stockcode," ");
}
Stock(char na[],int q=1000,double p=8.98);/*{
strcpy(stockcode,na);
quan=q;
price=p;
}*/
void show();
private:
char stockcode[size];
int quan;
double price;
};
Stock::Stock(char na[], int q=1000, double p=8.98){
strcpy(stockcode,na);
quan=q;
price=p;
}
void Stock::show(){
cout<<this->stockcode<<" "<<this->quan<<" "<<this->price<<endl;
}
int main(){
Stock s1("600001",3000,5.67);
s1.show();
Stock s2("600002");
s2.show();
return 0;
}



