Spspecify a class item having data members item number and item cost also specify two member function getdata() and putdata() create object of item class and called the function
#include<iostream>
using namespace std;
class Item
{
int itNumber;
double itCost;
public:
Item(int _itNumber, int _itCost):itNumber(_itNumber),itCost(_itCost){}
Item(){}
void putdata()
{
cout << "\nPlease, enter an item number: ";
cin >> itNumber;
cout << "Please, enter an item cost: ";
cin >> itCost;
}
void getdata()
{
cout << "\nItem number is "<<itNumber;
cout << "\nItem cost is " << itCost;
}
};
int main()
{
Item a(1, 80);
a.getdata();
Item b;
b.putdata();
b.getdata();
}
Comments
Leave a comment