当前位置: 首页 > news >正文

承德网站制作多少钱选择锦州网站建设

承德网站制作多少钱,选择锦州网站建设,网页设计网站多少钱,开发一个进销存app需要多少钱1、货物出货与进货 #if 0 #includeiostream using namespace std; /* 某商店经销一种货物。货物购进和卖出时以箱为单位。各箱 的重量不一样#xff0c;因此商店需要记录目前库存的总重量#xff0c;现在用 C模拟商店货物购进和卖出的情况 */ class Goods { public:…1、货物出货与进货 #if 0 #includeiostream using namespace std; /* 某商店经销一种货物。货物购进和卖出时以箱为单位。各箱 的重量不一样因此商店需要记录目前库存的总重量现在用 C模拟商店货物购进和卖出的情况 */ class Goods { public:Goods() {weight 0;next NULL;cout 创建了一个重量为 weight 的货物 endl;}Goods(int w) {//需要创建一个w的货物并且仓库加这个重量weight w;next NULL;total_weight w;cout 创建了一个重量为 weight 的货物 endl;}static int get_total_wight() {return total_weight;}~Goods() {//需要删除一个w的货物并且仓库减这个重量cout 删除了一个重量为 weight 的货物 endl;total_weight - weight;} public:Goods *next; private:int weight;static int total_weight; }; int Goods::total_weight 0; void buy(Goods *head, int w) {//创建一个货物 重量为wGoods *new_goods new Goods(w);if (head NULL)head new_goods;else {new_goods-next head; //头结点插入head new_goods;} } void sale(Goods * head) {if (head NULL) {cout 仓库为空 endl;return;}Goods *temp head;head head-next;delete temp;cout saled. endl; } int main(void) {int choice 0;int w;Goods *head NULL; //利用链表管理 无头指针do{cout 1 进货 endl;cout 2 出货 endl;cout 0 退出 endl;cin choice;switch (choice){case 1:cout 请输入要创建货物的重量 endl;cin w;buy(head, w);break;case 2:sale(head);break;case 0:return 0;break;default:break;}cout 当前仓库的总重量是 Goods::get_total_wight() endl;} while (1); } #endif 我的思路 #if 0 #includeiostream using namespace std; /* 某商店经销一种货物。货物购进和卖出时以箱为单位。各箱 的重量不一样因此商店需要记录目前库存的总重量现在用 C模拟商店货物购进和卖出的情况 */ class Goods { public:Goods(int num, int weight) {m_num num;m_weight weight;}void get_in_good() {m_sum_weight m_num*m_weight;}void get_out_good(int num, int weight) {m_sum_weight - num*weight;}static int get_m_sum_weight(){return m_sum_weight;} private:int m_num;int m_weight;static int m_sum_weight; }; int Goods::m_sum_weight 0; int main() {Goods g1(1, 20);Goods g2(2, 30);Goods g3(3, 50);g1.get_in_good();g2.get_in_good();g3.get_in_good();g2.get_out_good(1, 30);cout Goods::get_m_sum_weight() endl;return 0; } #endif 2、数组类的封装 MyArray.h #pragma once #includeiostream using namespace std; class MyArray { public:friend ostream operator(ostream os, const MyArray obj);friend istream operator(istream os, MyArray obj);friend bool operator(const MyArray a1, const MyArray a2); //全局函数bool operator!(const MyArray another); //成员函数MyArray();MyArray(int length);MyArray(const MyArray obj);MyArray operator(const MyArray obi);int operator[](int index) const; void setData(int index, int value);int getData(int index);int getLength() const;~MyArray(); private:int m_length;int *m_space; //指向堆上空间 数组首地址 }; MyArray.cpp #include MyArray.hMyArray::MyArray() {cout MyArray() endl;m_length 0;m_space NULL; } MyArray::MyArray(int length){/*if (length 0){m_length 0;m_space new int[length];}else {m_length length;m_space new int[length];}*///等价于if (length 0){length 0;}m_length length;m_space new int[length]; } MyArray::MyArray(const MyArray obj) {if (obj.m_length0){ if (m_space ! NULL) {delete[] m_space;m_space NULL;}this-m_length obj.m_length;this-m_space new int[this-m_length];for (int i 0; i m_length; i) //数据元素深拷贝{this-m_space[i] obj.m_space[i];}} } MyArray::~MyArray() {if (m_space ! NULL) {delete[] m_space;m_space NULL;} } MyArray MyArray::operator(const MyArray another) {if (this another){return *this;}if (this-m_space ! NULL) {delete this-m_space;this-m_space NULL;this-m_length 0;}if (another.m_length 0){this-m_length another.m_length;this-m_space new int[this-m_length];for (int i 0; i m_length; i) //数据元素深拷贝{this-m_space[i] another.m_space[i];}}return *this; } int MyArray::operator[](int index) const{return this-m_space[index]; }void MyArray::setData(int index, int value) {if (m_space ! NULL) {//a1.setData(i, i);m_space[index] value;}} int MyArray::getData(int index) {return m_space[index]; } int MyArray::getLength() const {return m_length; } bool MyArray::operator!(const MyArray another) {/*if (this-getLength() ! another.getLength()) {return true;}for (int i 0; i this-getLength(); i) {if (this-m_space[i] ! another.m_space[i])return true;}return false;*///等价于return !(*this another); } ostream operator(ostream os, const MyArray obj) { //防止被修改添加const后报错//原因分析在调用getLengt()传入的是obj,并不是const类型//安全性高的转换为安全性低的会报错//下面的operator[](obj)传入的是obj,并不是const类型 所以报错//修改方法就是加上在getLength() 函数后添加const//修改方法就是加上在operator[](int index)函数后添加constos 遍历整个数组 endl;//for (int i 0; i obj.m_length; i) 无法修改for (int i 0; i obj.getLength(); i){//os obj.m_space[i] ;//等价于os obj[i] ;}return os; } //istream operator (istream is,MyArray obj) { // cout 请输入数组元素个数; // cin obj.m_length; // obj.m_space new int[obj.m_length]; // for (int i 0; i obj.m_length; i) // { // int j; // cin j; // obj.m_space[i] j; // } // return is; // //} istream operator(istream is, MyArray array) {cout 请输入 array.getLength() 个数 endl;for (int i 0; i array.getLength(); i){cin array[i];}return is; } bool operator(const MyArray a1, const MyArray a2) {if (a1.getLength() ! a2.getLength()) {return false;}for (int i 0; i a1.getLength(); i){if (a1.m_space[i] ! a2.m_space[i])return false;}return true; } main.cpp #includeiostream using namespace std; #includeMyArray.hint main() {MyArray a1(10);for (int i 0; i a1.getLength(); i){//a1.setData(i, i);a1[i] i 10; //space[i]i10}cout print a1 endl;for (int i 0; i a1.getLength(); i){//couta1.getData(i) ;cout a1[i] ;}MyArray a2 a1;cout endlprint a2 endl;for (int i 0; i a2.getLength(); i){//couta1.getData(i) ;cout a2[i] ;}cout endl;MyArray a3;a3 a1;cout endl print a3 endl;for (int i 0; i a3.getLength(); i){//cout a3.getData(i) ;cout a3[i] ;}cout endl 操作符重载 endl;cout a3 endl;MyArray array1(3);cin array1;cout array1 endl;if (array1 a1) {cout 相等 endl;}elsecout 不相等 endl;if (array1 ! a1) {cout 不相等 endl;}elsecout 相等 endl; }
http://www.sadfv.cn/news/179565/

相关文章:

  • 网站建设的讲话稿网站服务器多少钱一年
  • 大型网站seo方案网址ip查询域名解析
  • 企业怎么做网站推广织梦网站打开空白
  • 装修网站是怎么建设的淄博高端网站建设
  • 网站建设的ppt模板建设银行网站登录不了
  • 科普网站建设自己做的网站加载速度慢
  • 建设网站需要做什么什么是网络营销啊
  • 常州装修网站建设公司重庆网站seo案例
  • 财务公司代理记账怎么收费淘宝怎么优化关键词步骤
  • 网站开发需求列表个人网站建站教程
  • 珠海建设企业网站的公司玉林建设信息网站
  • 北京网页网站设计制作wordpress如何页面静态
  • 怎么把自己做的网站让别人收到优质网站排名公司
  • 专业建站服务建站网室内设计考研
  • 群晖nas做网站域名个人网站需要什么页面
  • 建设网站如企业如何找网络公司做网站
  • 四川省级建设主管部门网站哪个网站有利于做课件
  • 外币投资理财网站开发苏州企业建站系统模板
  • 网站优化工作内容住房和城乡建设部网站中国建造师网
  • php做的购物网站长春房产网
  • 深圳商城网站建设报价网页源代码查看答案
  • Wordpress内部页面链接网站seo关键词优化技巧
  • 网站管理系统有哪些江门建站软件
  • 外包做的网站可以直接去收录吗wap网站做视频直播
  • 视频网站建设类图重庆论坛建站模板
  • 制作网站公司定价wordpress登录后台不显示登录
  • 手机网站开发费用供电公司网站建设内容
  • 网站建设和网络推广外包服务商wordpress 分页功能
  • 网站项目分析怎么做 方法网站地图表现形式
  • 优化网站的公司哪家好为什么做织梦网站时图片出不来