I have getter setter function like this.
void Student::setStudentName(std::__cxx11::string b)
{
cout<<"Enter the student name"<<endl;
cin >> studentName;
int size = b.size();
if(size > 0 && size<20)
studentName = b;
else
cout<<"Please enter a name between 1-20 char"<<endl;
}
string Student::getStudentName() const
{
return studentName;
}
What i want to do is add to the list with getter function.
void Student::addStudent()
{
int studentAdd;
cout<<"How many student do you want to add?"<<endl;
cin>>studentAdd;
for(int i=0;i<studentAdd;++i)
{
setStudentName("a");
getStudentList().push_back(getStudentName());
}
}
I tried like this but
getStudentList().push_back(getStudentName());
this code didn't work. What could be the problem?
And here is the list's getter/setter
void Student::setStudentList(list<string> a)
{
studentList = a;
}
list<string> Student::getStudentList() const
{
return studentList;
}