I'm working on a school project with C++, I'm using constructors. I will have a basic school system, which will consist on working with students name, student id, student grades (with will be the float array[]) and an optional substitution test.
I'm having problems when assigning the float array to the values I have declared on the main function.
This is the function.cpp file:
#include "aluno.h"
#include <stdio.h>
#include <string.h>
#include <string>
#include <iostream>
using namespace std;
Aluno::Aluno(){
cout << "Objeto 1 inicializado!\n";
}
Aluno::Aluno(char* name, int rgm, float notas[2], float nota_sub){
this->nome = name;
this->rgm = rgm;
this->notas = notas;
this->nota_sub = nota_sub;
cout << "Objeto 2 inicializado!\n";
}
Aluno::~Aluno(){
cout << "Aluno destruido: " << nome;
cout << "Objeto destruido!";
}
void Aluno::entrada(){
cout << "Digite seu NOME: ";
cin >> nome;
cout << "Digite seu RGM: ";
cin >> rgm;
cout << "Digite sua nota do primeiro bimestre: ";
cin >> notas[0];
cout << "Digite sua nota do segundo bimestre: ";
cin >> notas;
cout << "Digite sua nota da substutiva: ";
cin >> nota_sub;
}
When attempting to do this->notas = notas I get the following error:
expression must be a modifiable lvalueC/C++(137)
This is the .h file:
#ifndef ALUNO_H
#define ALUNO_H
class Aluno
{
private:
char* nome;
int rgm;
float notas[2];
float nota_sub;
public:
Aluno();
Aluno(char* name, int rgm, float notas[2], float nota_sub = 11);
~Aluno();
void entrada();
void imprime();
bool aprovado();
};
#endif
And the main file:
#include <iostream>
#include "aluno.h"
using namespace std;
int main()
{
float notas[2] = {5.3, 6.2};
Aluno aluno1("Nilton", 1904659, notas);
return 0;
}