0
過程中有錯誤,我有以下代碼編譯正確:可執行文件運行時
#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;
}
只要程序運行,可執行崩潰。任何想法爲什麼?
您的調試器以洞察力的方式提供了什麼?如果你是C++的新手,儘量避免使用'namespace std'這個壞習慣。 'std ::'前綴是故意的,它有助於避免與自己代碼中的名稱衝突。 – tadman
此處未顯示「投資」是什麼。在那裏可能會發生許多事情。有什麼理由爲什麼頭文件在全部大寫? – tadman
在for循環中,您使用的是*動態數組*,這不受C++標準支持。 –