0
中にエラーが発生したI正しくコンパイルし、次のコードを持っている:実行可能ファイルが実行
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include "INVESTMENT.h"
#include <vector>
using namespace std;
int main()
{
ifstream inputFile("jroth.csv");
string sHolder; //used as placeholder for string
float fHolder; //used as placeholder for float
double dHolder; ///used as placeholder for double
// while (inputFile.good())
vector<int> InvestVector; //will hold class (Investment) which contains string, double, and float
for (int i=0; i <= 7; i++)
{
Investment InvestVector[i]; //create new class for each line being pulled from .csv file
getline(inputFile, sHolder, ','); //pull in investment symbol as string
InvestVector[i].setSymbol(sHolder); //store string in the class
cout << InvestVector[i].getSymbol(); //verify string store properly
}
return 0;
}
とすぐにプログラムが実行されるよう、実行可能なクラッシュ。なぜどんな考え?
Investment InvestVector[i];
0からI-1までの番号「i」の場所を持つ配列を作成します。この行は、あなたが標準C++ではない可変長配列とC++コンパイラを使用していると仮定すると
洞察の仕方でデバッガは何を提供していますか?もしあなたがC++を初めて使っているのであれば、 'namespace stdを使う 'という悪い習慣を避けるようにしてください。 'std ::'プレフィックスは意図的なもので、独自のコード内の名前との衝突を避けるのに役立ちます。 – tadman
ここには「投資」とは何も表示されていません。そこにはどんな数のことが起こっているかもしれません。ヘッダーファイルがすべて大文字になっている理由はありますか? – tadman
'for'ループでは、C++標準ではサポートされていない*ダイナミック配列*を使用しています。 –