注册 登录
编程论坛 C++教室

各位大师,帮帮忙看看这个程序错在哪

张堪绘 发布于 2013-04-20 22:03, 520 次点击
#include<iostream>
using namespace std;
class Stock{
public:
    Stock(char na[],int q=1000,char p=8.98);
    void print()
    {cout<<"\nthis="<<this<<"stockcode,quan,price"<<this->stockcode,quan,price;}
private:
    char stockcode;
    int quan;
    double price;};
int main()
{Stock stock1(600001,3000.5.67);Stock stock2(600001);
stock1.print();

stock2.print();

return 0;}
3 回复
#2
user_qiangzi2013-04-20 22:08
Stock(char na[],int q=1000,char p=8.98);    //个人觉得是这里。
#3
张堪绘2013-04-20 22:11
那啥办
#4
马小柯2013-04-21 09:25
#include<iostream>
 using namespace std;
 class Stock{
 public:
     Stock(int na,int q=1000,double p=8.98);
     void print()
     {cout<<"\nthis="<<"stockcode,quan,price"<<stockcode<<"\t"<<quan<<"\t"<<price<<"\t";}
 private:
     int stockcode;
     int quan;
     double price;
     };
 Stock::Stock(int na,int q,double p)   
 {
     stockcode=na;
     quan=q;
     price=p;
 }
 int main()
 {
 Stock stock1(600001,3000,5.67);Stock stock2(600001);
 stock1.print();
 stock2.print();
 cout<<endl;
 return 0;
}
1