Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Create demo class and two member function 1st one is getting data and second one is display data*/
- #include<iostream.h>
- #include<stdio.h>
- #include<conio.h>
- class demo
- {
- //public:
- int age;
- char name[20];//data member;
- public: //private,protected,public (by def private)
- void getData()//member function
- {
- cout<<"\nEnter your name:";
- cin>>name;
- cout<<"\nEnter your age:";
- cin>>age;
- }
- void display()//member function
- {
- cout<<"\nYour name is "<<name<<" and age is "<<age;
- }
- };
- int main()
- {
- demo d1;//d1 is object
- clrscr();
- cout<<"\n\n";
- cout<<d1.age;
- d1.getData();
- d1.display();
- getch();
- return 0;
- }
Add Comment
Please, Sign In to add comment