Hi. I am trying to write a database on c++ to practice classes. I've created a class called PersonalData and the name is Person. Now, since the program is connected to a .txt file, which I want to be able to access directly from the program, the number of people in database will vary and therefore I want Person to be an array but it gives me an error: Invalid use of nonstatic data member. What on earth have I done?
here's a piece of code with the error.
class PersonalData
private:
int PeopleinDatabase;
PersonalData Person[PeopleinDatabase]; //ERROR HERE
short index;
string name;
short age;
public:
void AddPerson();
void ShowPeople();
void Loadpeople();
void DeletePerson();
void SaveToFile();
void SearchForPeople();
PersonalData ();
~PersonalData();
I apologise for the messy question, I'm pretty new to programming and this forum.
Thanks!