class Product
{
public:
Product();
Product(string n, double p, int s); /* new constructor */
bool is_better_than(Product b) const;
void print() const;
private:
string name;
float price;
int score;
};
Product::Product(string n, double p, int s )
{
name = n;
price = p;
score = s;
}
Product read() /* new non-member function */
{
cout << "Please enter the model name: ";
name = get_line(cin);
cout << "Please enter the price: ";
price = floatvalue(get_line(cin));
cout << "Please enter the score: ";
score = intvalue(get_line(cin));
return Product(name, price, score);
}
int main()
{
. . .
Product next;
next = read(); /* call non-member function */
. . .
}