Back To C++ Pointers
//program to create a pointer to an object of class student and access public members of class through pointer #include
#include
class student { int rollno; char name[20]; int marks; int clas; public: void getdata() { cout<<"enter rollno of the student "; cin>>rollno; cout<<"\nenter name of the student "; cin>>name; cout<<"\nenter marks of the student "; cin>>marks; cout<<"\nenter class of the student "; cin>>clas; } void showdata() { cout<<"\nrollno of the student is "<
getdata(); ptr->showdata(); getch(); }