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

宝塔做网站被逆冬seo课程欺骗了

宝塔做网站,被逆冬seo课程欺骗了,长沙哪里有网站推广优化,网页制作方案策划继承与动态内存分配 在基类或派生类中含有指针时#xff0c;要考虑内存分配情况#xff08;new与delete#xff09;#xff0c;还要考虑在进行对象间赋值时指针隐藏的问题#xff08;使用默认复制构造函数在析构时会造成原对象中的指针指向的内存空间被释放#xff0c;为…继承与动态内存分配 在基类或派生类中含有指针时要考虑内存分配情况new与delete还要考虑在进行对象间赋值时指针隐藏的问题使用默认复制构造函数在析构时会造成原对象中的指针指向的内存空间被释放为浅复制 因此需要 1. 重载运算符’‘、’‘实现深度复制 2. 在构造函数中使用new进行动态内存分配在析构函数中使用delete进行内存释放 3. 将析构函数声明为虚函数 在以下代码中还有一个小技巧来简化代码即代码重用在后续代码中使用已定义过的代码例如在C的构造函数中使用已经定义过的A的构造函数这样就可以只对C类新增的数据部分进行初始化。 #include iostream #include string #include cstring using namespace std;class A { private: char *label; //使用指针需要动态分配内存int a; public: A( const char* l null, int t 0 );A( const A t );virtual ~A();A operator( const A t );friend ostream operator( ostream out, const A t ); };class B : public A { private: enum{ COL_LEN 40 };char color[COL_LEN]; //使用数组不需要重新分配内存 public: B( const char *c blank, const char *l null, int t 0 );B( const char *c, const A t );friend ostream operator( ostream out, const B t ); };class C : public A { private: char *style; public: C( const char *s none, const char * l null, int t 0 );C( const char *s, const A t );C( const C t );~C();C operator( const C t );friend ostream operator( ostream out, const C t ); };// A methods A::A( const char *l, int t ) {label new char[ strlen(l) 1 ];strcpy( label, l );a t; }A::A( const A t ) {label new char[ strlen(t.label) 1 ];strcpy( label, t.label );a t.a; }A::~A() {delete[] label; }A A::operator( const A t ) {/* 若为同一对象则直接返回否则会将该对象内容delete无法复制 */if ( this t ) {return *this;}delete[] label; //先释放原内存空间label new char[ strlen(t.label)1 ];strcpy( label, t.label );a t.a;return *this; }ostream operator( ostream out, const A t ) {out label t.label , a t.a endl;return out; }// B methods B::B( const char *c, const char *l, int t ) : A( l, t ) {strcpy( color, c ); }B::B( const char *c, const A t ) : A(t) {strcpy( color, c ); }ostream operator( ostream out, const B t ) {out ( const A )t;out color t.color endl;return out; }// C methods C::C( const char *s, const char *l, int t ) : A( l, t ) {style new char[ strlen(s)1 ];strcpy( style, s ); }C::C( const char *s, const A t ) : A( t ) {style new char[ strlen(s)1 ];strcpy( style, s ); }C::C( const C t ) : A(t) {style new char[ strlen(t.style)1 ];strcpy( style, t.style ); }C::~C() {delete[] style; }C C::operator( const C t ) {if ( this t ) {return *this;}A::operator(t); //调用A类的赋值函数初始化相当于 *this t;delete[] style;style new char[ strlen(t.style)1 ];strcpy( style, t.style );return *this; }ostream operator( ostream out, const C t ) {out ( const A )t; //类型强转使用A类的运算符重载函数out style t.style endl;return out; }int main() {A shirt( portabelly, 8 );B balloon( red, Blimpo, 4 );C map( Mercator, Buffalo, 5 );cout A:\n shirt endl;cout B:\n balloon endl;cout C:\n map endl;B balloon2(balloon);cout balloon2:\n balloon2 endl;return 0; }
http://www.zqtcl.cn/news/421403/

相关文章:

  • 网站建设需要哪些书籍免费做游戏网站
  • 杭州 网站定制做旅游网站宣传
  • 泉州市做网站优化建设地情网站的作用
  • 筑巢网络官方网站打开搜索引擎
  • 赣州做网站公司哪家好网站先做前端还是后台
  • wordpress关闭网站吗用织梦做的学校网站
  • 响应式网站建设平台东莞网站建设aj
  • 代码做网站的软件市场营销策划书
  • 东莞网站建设 手机壳文登建设局网站
  • 网站建设和后台空间管理关系企业网络需求分析
  • 做小说网站做国外域名还是国内的好温州市网站建设
  • wordpress识别手机跳转网站3d视频动画制作
  • 展示型企业网站设计方案邯郸市口碑网络技术有限公司
  • 网站配色案例泰州seo平台
  • wordpress标题title优化代码seo技术顾问
  • 怎么做直播网站的超管延安免费做网站
  • 织梦做手机网站hao123从网上开始
  • 网站制作公司十强重庆网站建设mlfart
  • 南京调查公司网站杭州一起做网站
  • 不关站备案wordpress内网网站模板
  • 做学术用的网站如果在各大网站做免费的网络推广
  • 设计素材网站线上网站数据报表
  • 做一个小型网站多少钱wordpress 手机商城模板
  • 谷歌网站收录提交金山网站建设关键词排名
  • 域名备案中网站可以开通个人网站开发多少钱
  • 西安维护网站广州公司网站设计制作
  • 荆门做网站网络推广公司多久能回本
  • 搜索网站存在的关键字室内设计公司排名榜
  • 响应式网页开发昆明网站排名优化公司哪家好
  • 如东建设局网站线上购物平台