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 >> person.name[i];cout << endl; // error here
            cout << "Please enter num of days : "; 
            cin >> person.days[i];cout << endl; // here


          }

       sort(begin(person),end(person),way_to_Sort);

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

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


       }



}

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.

This question has already been answered. Start a new discussion instead.