How to access a vector in a struct in C++? -


i trying access vector initialize in struct, when compile, print error:

mediaselec.cc: in function 'void leevector_conjunto(conjuntoestudiantes&)': mediaselec.cc:23:4: error: 'conjuntoestudiantes' has no member named 'asignaturas' v.asignaturas(num_asignaturas);

#include <vector> #include <iostream> using namespace std;  struct info{     int id_student;       //id of student     vector<double> marks; //contains marks of 1 student };  //typedef vector<int> subconjuntos; typedef vector<info> studentgroup;  /*read vector of n student group*/ void enter_group(studentgroup& v, subconjuntos& s) {     //size of studentgroup     int n;     cin >> n;     v = studentgroup (n);     //num. marks of 1 student     int num_marks;     cin >> num_marks;      //ignore part.     /*     //numero de subconjuntos     int s_subconjuntos;     cin >> s_subconjuntos;     s = subconjuntos (s_subconjuntos);     (int = 0; < n; ++i) {         cin >> s[i];      }     */      //read students marks , store in v.     (int = 0; < n; ++i) {         cin >> v[i].id_student;         (int j = 0; j < num_marks; ++j) {             cin >> v[i].marks[j];         }     } }   int main() {     studentgroup v;     //subconjuntos s;     enter_group(v,s); } 

where wrote

v.asignaturas(num_asignaturas); 

i think intended

v[n].asignaturas.resize(num_asignaturas); 

edit: when edited translate variable names english , show more code, line telling correct removed. necessary step.


Comments