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

内部劵网站怎么做网站推广常用方法

内部劵网站怎么做,网站推广常用方法,榆林市横山县建设局官方网站,广州网站的建设关于隐藏 (hidden) 假如继承以后&#xff0c;子类出现父类同名函数&#xff0c; 即使参数的形式不同&#xff0c; 也会导致父类的函数隐藏&#xff0c; 不参与函数匹配&#xff0c;不能使用。 这个链接讲的不错。https://zhuanlan.zhihu.com/p/575423511 #include <iostrea…

关于隐藏 (hidden)
假如继承以后,子类出现父类同名函数, 即使参数的形式不同, 也会导致父类的函数隐藏, 不参与函数匹配,不能使用。
这个链接讲的不错。https://zhuanlan.zhihu.com/p/575423511

#include <iostream>
using namespace std;
class Vehicle {
public:void accelerate() { cout << "Increasing speed: "; }
};
class Aeroplane : public Vehicle {public:void accelerate(int height) {cout << "Accelerating at a height of: " << height;}
};int main() {Aeroplane plane;plane.accelerate(1000);plane.accelerate();  //这里出错!main.cpp:17:25: error: no matching function for call to ‘Aeroplane::accelerate()’cout << endl;
}

如果子类的instance就是想调用父类的同名不同参的函数呢?方法有两个。

  1. 显式调用父类版本的函数
    b.A::func(); // 显式指定父类版本,合法
    #include
    using namespace std;
    class Vehicle {
    public:
    void accelerate() { cout << "Increasing speed: "; }
    };
    class Aeroplane : public Vehicle {
    public:
    void accelerate(int height) {
    cout << "Accelerating at a height of: " << height;
    }
    };

int main() {
Aeroplane plane;
plane.accelerate(1000);
plane.Vehicle::accelerate();
cout << endl;
}

  1. 用using
    using A::func; // 解开父类重载函数的默认隐藏。
#include <iostream>
using namespace std;
class Vehicle {
public:void accelerate() { cout << "Increasing speed: "; }
};
class Aeroplane : public Vehicle {public:using Vehicle::accelerate;void accelerate(int height) {cout << "Accelerating at a height of: " << height;}
};int main() {Aeroplane plane;plane.accelerate(1000);plane.accelerate();cout << endl;
}
  1. 当然也可以直接在子类的函数里面调用
class Aeroplane : public Vehicle {public:void accelerate(int height) {Vehicle::accelerate();  cout << "Accelerating at a height of: " << height;}
};

关于overload

关于override
如果不用virtual,怎么实现多态呢?可以用cast。但是对不同子类的object都要cast到对应的子类类型,显然很不方便。
static_cast<Circle *>(s)->draw();

#include <iostream>
#include <vector>using namespace std;class Shape {
public:void draw() { cout << "Drawing a generic shape...\n"; }
};class Circle: public Shape {
public:void draw() { cout << "Drawing a circle...\n"; }
};int main() {vector<Shape *> shapes;      // Vector of pointers to Shape instances// Create a pointer to a child class of Shape and append it to the vector shapes.push_back(new Circle);for (auto s: shapes)static_cast<Circle *>(s)->draw();      for (auto s : shapes)       // Release allocated memorydelete s;
}
http://www.ds6.com.cn/news/36159.html

相关文章:

  • 怎么做免费网站推国内营销推广渠道
  • 政府门户网站建设招标国内前10电商代运营公司
  • 经典的网站设计营销型网站建设的公司
  • 国外设计作品seo关键词优化推广价格
  • 外汇做单在什么网站网络营销七个步骤
  • 岳阳网站建设与设计永久不收费免费的软件
  • 新华书店的做的数字阅读网站专业软文发稿平台
  • 企业网站的功能主要有推广策划方案怎么写
  • 网站建设在哪里办公seo关键词推广话术
  • 临沂集团网站建设网站关键词全国各地的排名情况
  • 南通网站建设baidu tg培训心得简短50字
  • win7 iis设置网站首页宁波网站seo诊断工具
  • 网站怎么做不违法吗百度搜索引擎优化的推广计划
  • 华为展厅设计方案搜狗关键词优化软件
  • ssh课程网站开发百度关键词优化是什么意思
  • 求个免费网站好人有好报谷歌paypal下载
  • 做增员的保险网站电商培训机构排名
  • wordpress热门主题seo推广经验
  • 怎么给新公司做网站谷歌浏览器安卓版
  • 德州哪里有做网站推广的怎么办网站平台
  • 制作网站健康码防疫核验一体机
  • 个人网站备案要求顾问式营销
  • 网站的jsp页面怎么做现场直播的视频
  • 商城微网站模板免费网站友情链接
  • 怎么建立一个公司的网站吗百度招商客服电话
  • 3g版网站制作焊工培训
  • 做开箱的网站百度权重域名
  • 微网站 文章地推任务网
  • 通辽做网站0475seo网页制作公司排名
  • 申请做网站编辑组长的工作设想企业网站模板建站