Can somebody please tell me what is wrong in here or what does this error message means : " error
: reguest for member 'name' in 'person',which is of non-class type 'Person[2]' "

   struct Person{

       int days;
       string name;


const int size = 2;

  bool way_to_Sort(const Person &a, const Person &b) {return a.days < b.days;}

int main()
        Person person[size];

          for(int i = 0;i<=size;i++){

            cout << "Please enter a friend : "; 
            cin >>[i];cout << endl; // error here
            cout << "Please enter num of days : "; 
            cin >> person.days[i];cout << endl; // here



       for(int i = 0;i<size;i++){

          cout << "Names by days : " <<[i]<<endl; //here



You need to index person, not name


what a dump mistake. Thanks

Your array is made of Person objects. To select the ith object you would use person[i]. Then you would like to get to the name of this person which would be .name. Combing those you adress your ith name as person[i].name.
The same goes for your days.

The reason for this is that person[i] is a shortcut for value at (startpersonptr + offset i). This gives you your object at index i. This object will be of type Person, and you can use your calls methodes on it, so you can call your .name on it. You can however not call your .name on the array which is what you were trying to do.