当前位置:首页 > 内蒙古科技大学面向对象的程序设计实验6 静态成员和友元
}
void Goods::buy() {
cout<<\购入\
cout<<\请输入购入货物的重量:\ cin>>weight;
Goods::totalWeight += weight; weight = 0; }
void Goods::sell() {
cout<<\售出\
cout<<\请输入售出货物的重量:\ cin>>weight;
Goods::totalWeight -= weight; weight = 0; }
void main() {
inttwei=0; intswit=1;
cout<<\请设置初设总重量\ cin>>twei; Goods goods1(twei); while(swit) {
cout<<\请选择操作类型:0.退出 1.购入 2.售出\ cin>>swit; switch(swit) {
case 0:cout< case 1:goods1.buy(); goods1.PrintTotalWeight(); cout< case 2:goods1.sell(); goods1.PrintTotalWeight(); cout< 六、参考文献 参考的资料:C++面向对象程序设计
共分享92篇相关文档