class students { char *stud_name; int rollno; public: void set_values(char *n,int y) { stud_name=n; rollno=y; } }; int main() { char *name; int roll; int a; cout<<"enter the number of students"; cin>>a; students *ptr=new students[a]; for(int i=0;i<10;i++) { cout<<"enter the name and rollno of "<<i<<"th student"; cin.get(name,20); cin>>roll; *(ptr+i)->set_values(name,roll);//here is the error } return 0; }
ptr
*(ptr+i)->set_values(name,roll);//here is the error
(ptr+i)->set_values(name,roll);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)