注册 登录
编程论坛 VC++/MFC

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

张堪绘 发布于 2013-04-20 22:01, 575 次点击
#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;}
1 回复
#2
yuccn2013-04-21 09:39
#include<iostream>
using namespace std;
class Stock{
public:
    Stock(char na[],int q=1000,double p=8.98){quan =q;price=p;strcpy(stockcode, na);};
    void print()
    {cout<<"\nthis="<<(int)this<<"stockcode,quan,price"<<this->stockcode<<quan<<price;}
private:
    char stockcode[128];
    int quan;
    double price;};
    int main()
    {Stock stock1("600001",3000,5.67);Stock stock2("600001");
    stock1.print();
    stock2.print();
    return 0;}
1