#include<iostream> #include<string> using namespace std; class Product { public: Product(); Product(string na); Product(string na, double pr); void SetProduct(string na, double pr, string fa, bool ea, string co, double h); void output(); ~Product();
private: string name; double price; string factory; bool easy_break; string color; double high; };
Product::Product() { }
Product::Product(string na) { na = name; }
Product::Product(string na, double pr) { na = name; pr = price; }
void Product::SetProduct(string na, double pr, string fa, bool ea, string co, double h) { name = na; price = pr; factory = fa; easy_break = ea; color = co; high = h; }
void Product::output() { cout << name << " " << price << " " << endl; cout << factory<< " " << easy_break << " " << endl; cout << color << " " << high << " " << endl; }
Product::~Product() { } int main() { Product p1("car"); Product p2("glass", 3.00); p1.SetProduct("car", 100000.0, "nj", 0, "red", 1.5); p1.output(); return 0; }
|