sinat_36565459
sinat_36565459
采纳率66.7%
2017-03-05 11:16

一个无法解析的外部命令?

我写了一个包含类定义的头文件
#ifndef STOCKOO_H_
#define STOCK00_H_

#include////
using namespace std;

class Stock
{
private:
string company;
long shares;
double share_val;
double total_val;
void set_tot()
{
total_val = shares*share_val;
}
public:
void acquire(const string&co, long n, double pr);
void buy(long num, double price);
void sell(long num, double price);
void update(double price);
void show();
};

#endif

然后在cpp文件中写了类方法图片说明

#include
#include"cppstock00.h"
using namespace std;

void Stock::acquire(const string &co, long n, double pr)
{
company = co;
if (n < 0)
{
cout << "number of shares cant be negative;"
<< company << "shares set to 0.\n";
shares = 0;
}
else
shares = n;
share_val = pr;
set_tot();
}

void Stock::buy(long num, double price)
{
if (num < 0)
{
cout << "numbers of shares purchased cant be negative";
}
else
{
shares += num;
share_val = price;
set_tot();
}
}
void Stock::sell(long num, double price)
{
if (num < 0)
{
cout << "number of shares sold cant be negative.";
}
else if (num>shares)
{
cout << "you cant sell more than you have.";
}
else
{
shares -= num;
share_val = price;
set_tot();
}
}
void Stock::update(double price)
{
share_val = price;
set_tot();
}
void Stock::show()
{
cout << "company:" << company
<< "shares:" << shares << endl
<< "share price:" << share_val
<< "total" << total_val << endl;
}

编译后报错
无法解析的外部命令
无法解析的外部符号

小白求教这是怎么回事[捂脸]

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答