how am i getting the user to prompt something with out using the set parameter

the retailItem class stores the data about a product sold by the store. It has an item description, item number and the retail price

The retailitem class should include:
1-parameterized constructor which accepts the value
2-appropriate accessor methods only, getting the values of retailitem(not using mutator/set methods

class retailitem
{
private:
double RP // variable for retail price
string PD // variable for product description
string num1 // variable for item
public:
string getdescription() const;
string getItem () const;
double getRetailprice ();
}

Question?
if i cant set for the item how am i going to prompt the user to put in the information?
provide a constructor to initialize the values
how? can u show example
as
string retailitem::getItem()
{
return item;
}//end;
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class retailitem
{
private:
	double RP // variable for retail price
	string PD // variable for product description
	string num1 // variable for item
public:
	retailitem(double RP, string PD, string num1);
	string getdescription() const;
	string getItem () const;
	double getRetailprice ();
}

retailitem::retailitem(double RP, string PD, string num1);
:	RP(RP), 
	PD(PD),
	num1(num1)
{
}

You can now specify the values when you create the object
retailitem item(4.5, "haha", "hoho");
Topic archived. No new replies allowed.