Wpis z mikrobloga

Ktoś jakiś pomysł czemu nie dodaje mi studenta do grupy?

#include
#include

struct Student {
std::string imie;
std::string nazwisko;
std::vector oceny;
};

struct Group {
std::string nazwa;
std::vector st;
};

void addstudent(Group grp, Student student)
{
grp.st.push
back(student);
}

int main()
{
Student stsec;
Student st
thd;

stsec.imie = "Aleksander";
st
sec.nazwisko = "Sobiech";
stsec.oceny.pushback(6);
stsec.oceny.pushback(5.8);
stsec.oceny.pushback(5.11);

stthd.imie = "Andrzej";
st
thd.nazwisko = "Dziupla";
stthd.oceny.pushback(5.09);
stthd.oceny.pushback(5.81);
stthd.oceny.pushback(5.95);

Group grp;
grp.nazwa = "Grupa 7";
addstudent(grp, stthd);
addstudent(grp, stsec);

std::cout << grp.nazwa << "\n";
for (int i = 0; i < grp.st.size(); i++)
{
std::cout << grp.st[i].imie << " " << grp.st[i].nazwisko << "\n";
}

}

#programowanie #cpp
  • 4