Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*program to read and display details of a student*/
- #include<iostream.h>
- #include<conio.h>
- class student //class declaration
- {
- private : int rollno;
- char name[20];
- float m1,m2,m3;
- public : void display();
- void read();
- };
- void student :: read() //definition of member function outside class
- {
- cout<<"Enter Name of Student: ";
- cin>>name;
- cout<<"Enter Roll number: ";
- cin>>rollno;
- cout<<"Enter Mark Of Subject 1: ";
- cin>>m1;
- cout<<"Enter Mark of Subject 2: ";
- cin>>m2;
- cout<<"Enter Mark of subject 3: ";
- cin>>m3;
- }
- void student :: display()
- {
- cout<<name;
- cout<<rollno;
- cout<<"Mark 1: "<<m1;
- cout<<"Mark 2: "<<m2;
- cout<<"Mark 3: "<<m3;
- }
- int main() //main function
- {
- student obj1;
- obj1.read();
- obj1.display();
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment