Проблема компиляции класса

Продолжайте получать эти ошибки при попытке компиляции программа класса C ++.

testStock.cpp: в функции int main (): testStock.cpp: 8: ошибка: «Акция» не была объявлена ​​в этой области testStock.cpp: 8: error: ожидается ; ' перед "первым" testStock.cpp: 9: error: "first" не было объявлен в этой области видимости testStock.cpp: 12: error: expected ; ' до "Second" testStock.cpp: 13: error: "second" не было объявлено в этом scope

stock.h

#ifndef STOCK_H
#define STOCK_H
using namespace std;

class Stock
{
 private:
  string symbol;
  string name;
  double previousClosingPrice;
  double currentPrice;
 public:
  Stock(string symbol, string name);
  string getSymbol() const;
  string getName() const;
  double getPreviousClosingPrice() const;
  double getCurrentPrice() const;
  double changePercent();
  void setPreviousClosingPrice(double);
  void setCurrentPrice(double);
};

#endif

stock.cpp

#include <string>
#include "stock.h"

Stock::Stock(string symbol, string name)
{
  this->symbol = symbol;
  this->name = name;
}

string Stock::getSymbol() const
{
  return symbol;
}

string Stock::getName() const
{
  return name;
}

void Stock::setPreviousClosingPrice(double closing)
{
  previousClosingPrice = closing;
}

void Stock::setCurrentPrice(double current)
{
  currentPrice = current;
}

double Stock::getPreviousClosingPrice() const
{
  return previousClosingPrice;
}

double Stock::getCurrentPrice() const
{
  return currentPrice;
}

double Stock::changePercent() 
{
  return ((currentPrice - previousClosingPrice)/previousClosingPrice) * 100;
}

testStock.cpp

#include <string>
#include <iostream>
#include "string.h"
using namespace std;

int main()
{
  Stock first("aapl", "apple");
  cout << "The stock symbol is " << first.getSymbol() << " and the name is " << first.getName() << endl;
  first.setPreviousClosingPrice(130.0);
  first.setCurrentPrice(145.0);
  Stock second("msft", "microsoft");
  second.setPreviousClosingPrice(30.0);
  second.setCurrentPrice(33.0);
  first.changPercent();
  second.changePercent();
  cout << "The change in percent for " << first.getName << " is " << first.changePercent() << endl;
  cout << "The change in percent for " << second.getName << " " << second.getSymbol() << " is " << second.changePercent() << endl;

  return 0;
}

Я уверен, что это что-то очевидное, но это только моя программа второго класса.

0
задан Sean 15 February 2012 в 19:41
поделиться