Xem giúp đoạn code struct vector

Mình có đoạn code nhỏ nhỏ để đọc dữ liệu từ file, mình muốn quản lý nó trong một cái struct, mà sao nó ko chạy đc nơi. Nhờ mấy bạn xem giúp mình với, thanks:

#include <iostream>
#include <vector>
#include <fstream>

 using namespace std;
 struct Record {

 int id;
int age;

};
int main ()
{ 
 vector <Record> record;
 ifstream data_in ("test.txt");
int id;
    int age;
    while (data_in>>id>>age)
    {
        record.push_back(id,age);
    }

 }
struct Record{
   int id,age;
   Record(int id_,int age_){ id=id_;age=age_;}
}

...

record.push_back(Record(id,age));
1 Like

Problem fixed, thanks!

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?