'Using push_back for a vector within a structure

I am a newbie to C and C++, and am trying to use vectors for a specific problem. I have used the example below and can load the contents of both structures into "both" vectors. However, I need to be able to use "push_back" to load the "assessment" structure values (as well as the "subject" details). Is this possible? Any assistance would be most appreciated:-)

#include <vector>

using namespace std;

struct assessment {
int   points;
int   total;
};

struct subject {
string name;
int    marks;
int    credits;
vector<assessment> assessments;
};

int main() {
vector<subject> sub {
{"english", 10, 0, {assessment{1,3,0.33f},
assessment{2,3,0.66f},
assessment{3,3,1.00f}
}
},
{"math"   , 20, 5, {assessment{2,4,0.50f}
}
}
};
}

I have tried first loading both structures with "dummy" data, and can add to the "subject" using push_back, but can't figure out the syntax to do the same for "assessments" I was hoping to be able to do something like:-

assessment a;
a.points=20;
a.total=50;

sub.assessments.push_back(a);

The error I get is:- std::vector<subject>' has no member named 'assessments'



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source