Back To C++ Classes
in the code given below, class student has two member functions getdata() and showdata() which are defined outside the class
//program to demonstrate example of class student with member functions defined outside the class (member functions can be referred using scope resolution operator :: #include
#include
class student { int rollno; char name[20]; int clas; float marks[3]; public: void getdata(); void showdata(); }; void student::getdata() { int i; cout<<"\nenter rollno of student "; cin>>rollno; cout<<"\nenter name of student "; cin>>name; cout<<"\nenter class of student "; cin>>clas; for(i=0;i<3;i++) { cout<<"\nenter marks of student in subject "<
>marks[i]; } } void student::showdata() { int i; cout<<"\nrollno of student is "<