电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

编程题3_4_产品类Product的设计

编程题3_4_产品类Product的设计_第1页
1/7
编程题3_4_产品类Product的设计_第2页
2/7
编程题3_4_产品类Product的设计_第3页
3/7
名称 编程题3_4: 产品类Product 的设计 备注 描述 设计一个产品类 Product ,允许通过如下方式来创建产品对象: 通过指定产品名创建; 通过指定产品名和产品价格创建; 通过指定产品名、产品价格、出厂日期(对象成员)创建; Product 还应该包含如下属性:生产厂家、易碎标记、有效日期(使用对象成员)。设计该类时请至少增加 3 个其他属性。成员函数包括访问和修改这些属性的操作。 在 main( ) 中定义对象,并输出相关信息。 相关类的定义提示: class Product { char *name; double price; Date deptime; char *factory; bool easy_break; Date valtime; ........ public: ........ void output ( ); }; 输出函数提示 : void Product::output ( ) { cout< using namespace std; class Date { int year,month,day; public: Date(int y=2000,int m=1,int d=1) { year=y; month=m; day=d; } int Getyear() {return year; } int Getmonth() { return month; } int Getday() 参考源代码仅供老师参考,不要添加到系统中 { return day; } void settime(int y,int m,int d) { year=y;month=m;day=d; } }; class Product { char *name; double price; Date deptime; char *factory; bool easy_break; Date valtime; char *color; double high; public: Product(char *na); Product(char *na,double pr); Product(char *na,double pr,int x,int y,int z); void SetProduct(char *na,double pr,int x,int y,int z,char *fa,bool ea,int a,int b,int c, char *co,double h); void output(); }; Product::Product(char *na) { name=new...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

编程题3_4_产品类Product的设计

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部