Let\'s say I have
#include
#include
using namespace std;
struct Student
{
const string name;
int grade;
Student(co
Elements of vectors must be copy-assignable, which your Student
struct isn't because of the const
member. Simply use string name
instead of const string name
.
Unless you have a specific requirement, constant members in classes are seldom useful. If you want to prevent changes to the member, make it private and add a public getter function.