'How to access the data member of one function into another function inside same class in c++
I wanted to declare the array of string to the limit provided by user. So I take limit in getData(), and declare the string inside getData function. As a whole I want to take students name and display it in the same class. Sorry for basic question and thank you in advance.
class student
{
int limit;
public:
void getData()
{
cout<<"Enter the number of students: ";
cin>>limit;
string name[limit];
cout<<"Enter the names of students: \n";
for(int i=0; i<limit; i++)
cin>>name[i];
}
void showData()
{
cout<<"The list of students: \n";
for(int i=0; i<limit; i++)
cout<<name[i]<<endl;
}
};
int main()
{
student s1;
s1.getData();
s1.showData();
return 0;
}
Here in this function, error comes as "name was not declared in this scope". sorry in advance if it is nonsense.
void showData()
{
cout<<"The list of students: \n";
for(int i=0; i<limit; i++)
cout<<name[i]<<endl;
}
Solution 1:[1]
The error lies in
Cell celda = fila.createCell(ultimaCelda);
where you create a new cell in the row. You can't add a cell, while iterating over the list of all cells. Try creating a copy of the list you are wanting to edit and iterate over that one instead, so the other one becomes editable
the java.util.ConcurrentModificationException appears,
when editing a list, that you are currently iterating over.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Log4JExploit |
