In C++ we know that for a pointer of class we use (->) arrow operator to access the members of that class like here:
#include <iostream>
using namespace std;
class myclass{
    private:
        int a,b;
    public:
        void setdata(int i,int j){
            a=i;
            b=j;
        }
};
int main() {
    myclass *p;
    p = new myclass;
    p->setdata(5,6);
    return 0;
}
Then I create an array of myclass.
p=new myclass[10];
when I go to access myclass members through (->) arrow operator, I get the following error:
base operand of '->' has non-pointer type 'myclass'
but while I access class members through (.) operator, it works. These things make me confused. Why do I have to use the (.) operator for an array of class?
 
     
     
     
     
     
     
     
    