So i have a pretty straight foward homework that consist in creating a student class that has a name and 3 grades as attributes and a method to caluculate the final grade and append the name as well as the final grade to 2 vectors respectively, the problem comes up when i try to append the name to the vector as its appended as an empty string, but the debugger shows the instance of that student class (the "Alumno" class) has actually a name.
i'll leave you the code below,
class libroDeClases {
public:
vector<string> nombres;
vector<float> notasDef;
};
class Alumno {
private:
string nombre;
float n1, n2, n3;
float notaDef;
public:
Alumno(string nombre, float x, float y, float z) {
nombre = nombre;
n1 = x;
n2 = y;
n3 = z; }
void calcularNota(libroDeClases L) {
float nd = (n1 + n2 + n3) / 3;
notaDef = nd;
L.notasDef.push_back(nd);
L.nombres.push_back(nombre);
}
int main() {
libroDeClases Libro;
Alumno a1("Oscar", 4.0, 4.7, 5.5);
a1.calcularNota(Libro);
thank you for your help!
Edit: i added the "Libro" class in order to make the code compile, i forgot to provide it sorry about that.