0

私のプログラムは、ファイルからデータを読み取り、画面に出力するか、ファイルに書き込む自動化された株式市場です。ファイルを読み取って画面に表示することはできますが、ゲインを計算しようとするとエラーが発生します。以下は私のコードです:

istream& operator>>(istream& ins, stockType& stock)
 {//member variables are all declared as a double
   ins>>stock.todays_open_price
      >>stock.todays_close_price
      >>stock.todays_high_price
      >>stock.prev_low_price
      >>stock.prev_close_price;
      calculateGain(stock.todays_close_price, stock_prev_close_price);
      return ins;
  }

 void stockType::calculateGain(double close, double prev)
        {  // gain was declared in the header file as a private member
           //variable to store the gain calculated.
           gain = ((close-prev)/(prev));
         }
  ostream& operator<<(ostream& outs, const stockType& stock)
  {        
     outs<<stock.getOpenprice()
         <<stock.getCloseprice()
         <<stock.getPrevLowPrice()
         <<stock.getPrevClosePrice()
         <<stock.getGain()
         return outs
   }

    //double getGain() was declared in the header file also as
     double getGain() {return gain;}

以下は私が得ているエラーです:stockType.cpp:関数 'std::ifstream& operator>>(std::ifstream&, stockType&)':stockType.cpp:38:エラー:'calculateGain'はこのスコープで宣言されていませんでした

4

1 に答える 1