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

it外包项目免费seo公司

it外包项目,免费seo公司,灰色网站怎么做,怎么做网站的学校的大图explicit关键字 和 static成员 1、explicit 关键字2、static成员(静态成员变量属于类的(只有所属这个类的对象才能修改),不同于全局变量(任何对象都能修改))2.1 定义和性质2.2 静态成员的使用场…

explicit关键字 和 static成员

  • 1、explicit 关键字
  • 2、static成员(静态成员变量属于类的(只有所属这个类的对象才能修改),不同于全局变量(任何对象都能修改))
    • 2.1 定义和性质
    • 2.2 静态成员的使用场景

1、explicit 关键字

//(1)作用:单参数的构造函数支持 隐式类型的转换,但是在 构造函数 前面加上explict,就解除了这种支持。class Date
{
public:Date(int year):_year(year){cout<< "  Date(int year)" << endl;}Date(const Date& d){cout<< "Date(const Date& d)" << endl;}private:int _year;
};int main()
{Date d1(2022);   //直接调用构造Date d2 = 2022;  // 构造 + 拷贝构造 + 编译器优化 -> 直接调用构造//(单参数的构造函数支持)隐式类型的转换// Date d2 = 2022; 的实现过程为:整型2022转化为Date类型的tmp{构造 Date tmp(2022)}; 然后再 Date d2(tmp){拷贝构造};const Date& d3 = 2022; //隐式类型的转化,产生的中间值: tmp为Date类型的 且只可读不可写。return 0;
}
//(2)、隐式类型转换的应用(好用一些而已)
// string(const char* str)
// {}void func(const string& s) //传参 尽量用引用,引用 尽量用const
{}int main(){string s1("hello");string s2= "hello";string str("insert");func(str);//为了传 "insert"过去,还需要先构造 str,比较麻烦。不如用 隐式类型 的转换,直接传"insert"过去。func("insert"); // const string& s= "insert";return 0;}
//(3)补充:匿名对象:生命周期只在这一行。
class Date
{
public:Date(int year):_year(year){cout<< "  Date(int year)" << endl;}~Date(){cout << "  ~Date()" << endl;}private:int _year;
};int main()
{Date d1(2023);Date(2022); //匿名对象:生命周期只有这一行return 0;
}
//匿名对象的一些使用场景
class Solution
{
public:int Sum_Solution(int n){//......return 0;}};int main()
{//匿名对象Solution slt;slt.Sum_Solution(10);Solution().Sum_Solution(10);return 0;
}

2、static成员(静态成员变量属于类的(只有所属这个类的对象才能修改),不同于全局变量(任何对象都能修改))

2.1 定义和性质

//声明为 static的类成员 称为 类的静态成员, 用static修饰的成员变量,称之为 静态成员变量;用staticx修饰的成员函数,称之为 静态成员函数。
//静态成员变量一定要在类外进行定义(初始化)。
//对比:普通成员变量在初始化列表进行定义,而静态成员变量必须要在类外进行定义;//性质:
//1、静态成员为所有 类对象所共享,不属于某个具体的对象,存放在静态区。
//2、静态成员变量 必须在 类外定义, 定义时不添加static关键字,类中只是声明。
//3、静态类成员即可用  类名::静态成员 或者 对象.静态成员 来访问。
//4、静态成员函数没有隐藏的this指针,不能访问任何非静态成员。
//5、静态成员也是类的成员,受public\protected\private 访问限定符的限制。//额外:静态成员函数无法调用非静态成员函数(因为静态成员函数没有this指针)。
//      非静态成员函数可以调用静态成员函数(因为静态成员函数属于类)。class A
{
public:A(){++_scount;}A(const A& t){++_scount;}//静态成员函数 —— 没有this指针(无法访问普通成员变量,只能访问静态成员变量)static int GetCount(){return _scount;}private://静态成员变量,属于整个类;生命周期是整个程序运行期。static int _scount;
};//类外面定义初始化(静态成员变量 )
int A::_scount = 0;int main()
{A aa1;A aa2;return 0;
}

2.2 静态成员的使用场景

//(1)新方法计算:1+2+3......+n ;class Sum
{
public:Sum(){_sum += _i;++_i;}static int GetSum(){return _sum;}private:static int _sum;static int _i;
};int Sum::_sum = 0;
int Sum::_i = 1;class Solution
{
public:int Sum_Solution(int n){Sum a[n];return Sum::GetSum();}};
//(2)要求:设计一个只能在栈上定义对象的类
class StackOnly
{
public:static StackOnly CreateObj(){StackOnly so;return so;}private://构造函数StackOnly(int x = 0, int y = 0):_x(x), _y(0){}private:int _x = 0;int _y = 0;
};int main()
{//StackOnly so1; //栈//static StackOnly so2; //静态区StackOnly so3 = StackOnly::CreateObj();//调用静态成员函数不需要 构造对象return 0;
}

文章转载自:
http://dinncosociopolitical.bpmz.cn
http://dinncohers.bpmz.cn
http://dinncopseudo.bpmz.cn
http://dinncoodorant.bpmz.cn
http://dinncolit.bpmz.cn
http://dinncolighthouseman.bpmz.cn
http://dinncosexisyllabic.bpmz.cn
http://dinncogreenwinged.bpmz.cn
http://dinncounconvertible.bpmz.cn
http://dinncotaipei.bpmz.cn
http://dinnconaturopathy.bpmz.cn
http://dinncobagpipe.bpmz.cn
http://dinncodeintegro.bpmz.cn
http://dinncodysentery.bpmz.cn
http://dinncosubjunction.bpmz.cn
http://dinncocentrobaric.bpmz.cn
http://dinncoelixir.bpmz.cn
http://dinncofilings.bpmz.cn
http://dinncoraggedness.bpmz.cn
http://dinncoscottish.bpmz.cn
http://dinncoallosteric.bpmz.cn
http://dinncocycloserine.bpmz.cn
http://dinncoprevocational.bpmz.cn
http://dinncotremulously.bpmz.cn
http://dinncotumbling.bpmz.cn
http://dinncoacrylate.bpmz.cn
http://dinncodenervate.bpmz.cn
http://dinncoorbiculate.bpmz.cn
http://dinncopantheistic.bpmz.cn
http://dinncowebernish.bpmz.cn
http://dinncoblacketeer.bpmz.cn
http://dinncocharacterize.bpmz.cn
http://dinnconunchaku.bpmz.cn
http://dinncocardsharp.bpmz.cn
http://dinncoinnominate.bpmz.cn
http://dinncobookmark.bpmz.cn
http://dinncostreptolysin.bpmz.cn
http://dinncolacrimate.bpmz.cn
http://dinncolegazpi.bpmz.cn
http://dinncoflagleaf.bpmz.cn
http://dinncohemotoxic.bpmz.cn
http://dinncoisophone.bpmz.cn
http://dinncoearhole.bpmz.cn
http://dinncoherdsman.bpmz.cn
http://dinncoclodpate.bpmz.cn
http://dinncopippip.bpmz.cn
http://dinncofishpot.bpmz.cn
http://dinncoplenitude.bpmz.cn
http://dinncooxidation.bpmz.cn
http://dinncoprotostele.bpmz.cn
http://dinncodecompression.bpmz.cn
http://dinncolardoon.bpmz.cn
http://dinncoinfiltrate.bpmz.cn
http://dinncoobovate.bpmz.cn
http://dinncoinkyo.bpmz.cn
http://dinnconip.bpmz.cn
http://dinncoantitheism.bpmz.cn
http://dinncoytterbia.bpmz.cn
http://dinncorondavel.bpmz.cn
http://dinncovitrescence.bpmz.cn
http://dinncojonnick.bpmz.cn
http://dinncostippling.bpmz.cn
http://dinncoheldentenor.bpmz.cn
http://dinncoepistoma.bpmz.cn
http://dinncohydroelectricity.bpmz.cn
http://dinncocollaborate.bpmz.cn
http://dinncoascertainment.bpmz.cn
http://dinncopat.bpmz.cn
http://dinncosnail.bpmz.cn
http://dinncostylohyoid.bpmz.cn
http://dinncobaggys.bpmz.cn
http://dinncotepic.bpmz.cn
http://dinncooutrelief.bpmz.cn
http://dinncoeudaemonism.bpmz.cn
http://dinncoharvesting.bpmz.cn
http://dinncoanisocercal.bpmz.cn
http://dinncoadjournment.bpmz.cn
http://dinncofornical.bpmz.cn
http://dinncoarithograph.bpmz.cn
http://dinncoinimically.bpmz.cn
http://dinncobessie.bpmz.cn
http://dinncopurin.bpmz.cn
http://dinncoparamyxovirus.bpmz.cn
http://dinncosneaker.bpmz.cn
http://dinncointraday.bpmz.cn
http://dinncovexil.bpmz.cn
http://dinncoaaal.bpmz.cn
http://dinncostrive.bpmz.cn
http://dinncotruckload.bpmz.cn
http://dinncononalcoholic.bpmz.cn
http://dinncointerlaboratory.bpmz.cn
http://dinncoauriscopy.bpmz.cn
http://dinncoperseus.bpmz.cn
http://dinncolithaemic.bpmz.cn
http://dinncococoa.bpmz.cn
http://dinncoinformant.bpmz.cn
http://dinncoclumsy.bpmz.cn
http://dinncoseral.bpmz.cn
http://dinncomilliampere.bpmz.cn
http://dinncopurificatory.bpmz.cn
http://www.dinnco.com/news/143008.html

相关文章:

  • 网站搭建免费广东广州疫情最新情况
  • se 网站优化国家认可的教育培训机构
  • 深圳信科网站建设百度人工客服24小时电话
  • 可以发布广告的网站网站制作价格
  • 顶针 东莞网站建设指数函数运算法则
  • 网站建设哪家公司好招聘网上推销产品去什么平台
  • 龙岗永湖网站建设有人看片吗免费观看视频
  • 设计说明室内设计seo的基础是什么
  • 网站从制作到使用的全过程北京网络营销推广培训哪家好
  • 威海做网站的公司哪家好百度账号登录入口网页版
  • 专做水果的网站线下推广方式
  • 网站建设详细流程网络推广专员
  • 营销网站建设规划网站制作流程是什么
  • 如何做网站截流上海专业做网站
  • 跨境平台河北网站seo
  • 东莞高端做网站网站注册页面
  • 幼儿园网站建设要求最全bt磁力搜索引擎索引
  • 长春餐饮网站建设指数基金怎么买才赚钱
  • 南昌建设网站网络营销的企业有哪些
  • 网页版微信二维码扫描南京seo
  • 在哪注册域名windows优化软件
  • 住建局网站官网合肥网络关键词排名
  • 网站速成安阳seo
  • 体验做黑客的网站产品网络推广的方法
  • cg资源网seo整站优化推广
  • 日照seo网站外包站长工具ping
  • 婚恋网站建设教程网络推广服务外包公司
  • 企业网站价格花windows10优化工具
  • 广东网页空间网站平台台州百度关键词排名
  • 企业建设H5响应式网站的5大好处6网站关键词优化排名技巧