次のようなクラスがあります。
class Test
{
public:
    Test() {}
    ~Test() {}
    //I kept these public for simplicity's sake at this point (stead of setters).
    int first_field;
    int second_field;
    int third_field;
    string name;
};
私の .txt ファイルは次のようになります。
1  2323   88   Test Name A1
2  23432  70   Test Name A2
3  123    67   Test Name B1
4  2332   100  Test Name B2
5  2141   98   Test Name C1
7  2133   12   Test Name C2
ファイルの各行をベクトルに読み込めるようにしたいので、現在のコードは次のようになります。
#include "Test.h"
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
    ifstream file;
    vector<Test> test_vec;
    file.open("test.txt");
    if(file.fail())
    {
        cout << "ERROR: Cannot open the file." << endl;
        exit(0);
    }
    while(!file.eof())
    {
        string input;
        if(file.peek() != '\n' && !file.eof())
        {
            Test test;
            file >> test.first_field >> test.second_field >> test.third_field;
            getline(file, input);
            test.name = input;
            test_vec.push_back(test);
        }
    }
    return 0;
}
だから、そのデータを読みたい部分で立ち往生しています...入力ストリーム演算子を試しましたが、何もしません。他のオプションではエラーが発生します。可能であれば、フォーマットも保持したいと思います。後でやりたいことは、そのベクトルをクラス内のさまざまなデータ フィールドでソートできるようにすることです。
何か案は?
編集: 問題は解決され、それを反映するようにコードが編集されました。助けてくれてありがとう。:)