Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program to declare class item to store item number and name of 5 objects.
- #include<iostream.h>
- #include<conio.h>
- #include<stdio.h>
- class item
- {
- private:
- int item_no;
- char item_name[80];
- public:
- void getdata()
- {
- cout<<"Enter item number: ";
- cin>>item_no;
- cout<<"Enter item name: ";
- gets(item_name);
- }
- void putdata()
- {
- cout<<"Item number is: "<<item_no<<endl;
- cout<<"Item name is: ";
- puts(item_name);
- cout<<endl;
- }
- };
- void main()
- {
- item a,b;
- a.getdata();
- b.getdata();
- a.putdata();
- b.putdata();
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment