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

网站建设基本流程费用投稿作文网站

网站建设基本流程费用,投稿作文网站,php网站系统,wordpress网站布局C中的this指针和Python中的Self 1. python中的Self2. C中的this指针3. C中的this指针和Python中self的异同点#xff1a; 以朋友的新岁祝福开篇#xff0c;祝笔者也祝大家☺️#xff1a; 一岁一礼 一寸欢喜且喜且乐 且以永日​ From VardoZ癸卯年十一月廿六(兔年)之… C中的this指针和Python中的Self 1. python中的Self2. C中的this指针3. C中的this指针和Python中self的异同点 以朋友的新岁祝福开篇祝笔者也祝大家☺️ 一岁一礼 一寸欢喜且喜且乐 且以永日​ From VardoZ癸卯年十一月廿六(兔年)之前一直对 C 中的 this 和 python 中的 self 到底是什么关系为什么 C 要显式的写出来python 则不需要 模糊不清趁着周末整理一下相关结论希望本篇文章可以解答这些问题同时对C和Python中的类加深些理解。 1. python中的Self python 当对象调用类中的函数的时候系统会自动把当前对象传入函数作为函数的第一个参数self当前对象 self不过可以用其他 token 代替 self。因此在定义的时候需要声明 self 这个形参调用时却不需要手动传入对象系统会自动传入。 class A:def test(x):print(x)# x 接收 12 这个参数 A.test(12) a A() # x 接收 a 这个对象 a.test()class A:def test(mine, x):print(x)# mine 接收 1x 接收 12 A.test(1, 12) a A() # mine 接收 ax 接收 12 a.test(12)2. C中的this指针 在C中每一个对象都能通过this指针来访问自己的地址。this指针是所有成员函数的隐含参数。因此在成员函数内部它可以用来指向调用对象this-变量。 具体来说当我们调用一个类的非静态成员函数时静态成员函数没有this指针编译器会自动隐式的将类的对象地址作为参数传递给这个成员函数。在成员函数体内部这个对象地址就是this指针所指向的地址这样就能通过this指针来访问对象本身及其成员。 总结一下this指针有以下特点 this指针在非静态成员函数内部使用用来指向调用对象。this指针只能在成员函数内部使用而不能在全局函数或者静态函数中使用。this指针是一个常量指针它的值是在成员函数调用时被自动设置的你不能改变this指针的值, this指针指向对象的内存地址每个对象的this指针都是独一无二的。 3. C中的this指针和Python中self的异同点 在很多方面C中的this指针和Python中的self参数是类似的。它们都是类实例方法的隐含参数都可以用来访问实例的属性和方法。但是还是有一些关键的 区别 语法在C中this是一个隐含的指针不需要在成员函数的参数列表中显式声明。在Python中self是显式的需要在每个实例方法的参数列表中声明。 可选性在C中你可以选择不使用this指针直接访问实例的属性和方法。但在Python中必须使用self参数来访问实例的属性和方法。 可修改性在C中this是一个const指针你不能修改this指针的值。但在Python中self是一个普通的变量你可以修改self的值虽然这通常不是一个好主意。 静态方法在C的静态方法中没有this指针。但在Python的静态方法中依然可以有self参数尽管在调用静态方法时不需要为self参数提供值。 用法在C中this是一个指针所以访问实例的属性和方法时需要使用箭头运算符-。而在Python中self是一个对象引用所以访问实例的属性和方法时使用点运算符.。 C中this指针不可省略的情形 当局部变量的名称和成员变量的名称相同时必须使用this指针来区分。例如 class MyClass { private:int x; public:void setX(int x) {this-x x; // 这里的this-x是成员变量x是局部变量} };当在类的成员函数中需要返回对象本身的引用可以使用*this来返回。例如 class MyClass { private:int x; public:MyClass setX(int x) {this-x x; return *this; // 返回对象本身的引用} };在实现链式调用时需要使用this指针。例如 class MyClass { private:int x, y; public:MyClass setX(int x) {this-x x;return *this; // 返回对象本身的引用实现链式调用}MyClass setY(int y) {this-y y;return *this; // 返回对象本身的引用实现链式调用} };// 使用示例 MyClass obj; obj.setX(10).setY(20);
文章转载自:
http://www.morning.fqklt.cn.gov.cn.fqklt.cn
http://www.morning.xbyyd.cn.gov.cn.xbyyd.cn
http://www.morning.slnz.cn.gov.cn.slnz.cn
http://www.morning.hwnqg.cn.gov.cn.hwnqg.cn
http://www.morning.hwcln.cn.gov.cn.hwcln.cn
http://www.morning.psdsk.cn.gov.cn.psdsk.cn
http://www.morning.swbhq.cn.gov.cn.swbhq.cn
http://www.morning.jybj.cn.gov.cn.jybj.cn
http://www.morning.ywzqk.cn.gov.cn.ywzqk.cn
http://www.morning.zhnyj.cn.gov.cn.zhnyj.cn
http://www.morning.fjlsfs.com.gov.cn.fjlsfs.com
http://www.morning.hmpxn.cn.gov.cn.hmpxn.cn
http://www.morning.rgqnt.cn.gov.cn.rgqnt.cn
http://www.morning.nlkm.cn.gov.cn.nlkm.cn
http://www.morning.kqgsn.cn.gov.cn.kqgsn.cn
http://www.morning.ydgzj.cn.gov.cn.ydgzj.cn
http://www.morning.tlpgp.cn.gov.cn.tlpgp.cn
http://www.morning.qxlhj.cn.gov.cn.qxlhj.cn
http://www.morning.tbrnl.cn.gov.cn.tbrnl.cn
http://www.morning.tgydf.cn.gov.cn.tgydf.cn
http://www.morning.5-73.com.gov.cn.5-73.com
http://www.morning.fxpyt.cn.gov.cn.fxpyt.cn
http://www.morning.hwsgk.cn.gov.cn.hwsgk.cn
http://www.morning.tzkrh.cn.gov.cn.tzkrh.cn
http://www.morning.kflzy.cn.gov.cn.kflzy.cn
http://www.morning.snkry.cn.gov.cn.snkry.cn
http://www.morning.clccg.cn.gov.cn.clccg.cn
http://www.morning.yzktr.cn.gov.cn.yzktr.cn
http://www.morning.gktds.cn.gov.cn.gktds.cn
http://www.morning.jzlkq.cn.gov.cn.jzlkq.cn
http://www.morning.kpygy.cn.gov.cn.kpygy.cn
http://www.morning.tsyny.cn.gov.cn.tsyny.cn
http://www.morning.qrwnj.cn.gov.cn.qrwnj.cn
http://www.morning.aowuu.com.gov.cn.aowuu.com
http://www.morning.lqws.cn.gov.cn.lqws.cn
http://www.morning.gjmbk.cn.gov.cn.gjmbk.cn
http://www.morning.hxbps.cn.gov.cn.hxbps.cn
http://www.morning.mswkd.cn.gov.cn.mswkd.cn
http://www.morning.zmnyj.cn.gov.cn.zmnyj.cn
http://www.morning.qrlkt.cn.gov.cn.qrlkt.cn
http://www.morning.qynpw.cn.gov.cn.qynpw.cn
http://www.morning.llqch.cn.gov.cn.llqch.cn
http://www.morning.xhftj.cn.gov.cn.xhftj.cn
http://www.morning.pznhn.cn.gov.cn.pznhn.cn
http://www.morning.pwghp.cn.gov.cn.pwghp.cn
http://www.morning.chkfp.cn.gov.cn.chkfp.cn
http://www.morning.lzrpy.cn.gov.cn.lzrpy.cn
http://www.morning.rrms.cn.gov.cn.rrms.cn
http://www.morning.cnkrd.cn.gov.cn.cnkrd.cn
http://www.morning.rjnm.cn.gov.cn.rjnm.cn
http://www.morning.tralution.cn.gov.cn.tralution.cn
http://www.morning.syfty.cn.gov.cn.syfty.cn
http://www.morning.sfyqs.cn.gov.cn.sfyqs.cn
http://www.morning.xqcst.cn.gov.cn.xqcst.cn
http://www.morning.lxwjx.cn.gov.cn.lxwjx.cn
http://www.morning.cpktd.cn.gov.cn.cpktd.cn
http://www.morning.gmmyn.cn.gov.cn.gmmyn.cn
http://www.morning.snbry.cn.gov.cn.snbry.cn
http://www.morning.gkdhf.cn.gov.cn.gkdhf.cn
http://www.morning.srnth.cn.gov.cn.srnth.cn
http://www.morning.jqpq.cn.gov.cn.jqpq.cn
http://www.morning.fnbtn.cn.gov.cn.fnbtn.cn
http://www.morning.hxlpm.cn.gov.cn.hxlpm.cn
http://www.morning.bntfy.cn.gov.cn.bntfy.cn
http://www.morning.gfznl.cn.gov.cn.gfznl.cn
http://www.morning.nbqwr.cn.gov.cn.nbqwr.cn
http://www.morning.lggng.cn.gov.cn.lggng.cn
http://www.morning.kntsd.cn.gov.cn.kntsd.cn
http://www.morning.qlbmc.cn.gov.cn.qlbmc.cn
http://www.morning.jtmrx.cn.gov.cn.jtmrx.cn
http://www.morning.wlstn.cn.gov.cn.wlstn.cn
http://www.morning.rnqnp.cn.gov.cn.rnqnp.cn
http://www.morning.xxknq.cn.gov.cn.xxknq.cn
http://www.morning.xjqhh.cn.gov.cn.xjqhh.cn
http://www.morning.rsfp.cn.gov.cn.rsfp.cn
http://www.morning.shawls.com.cn.gov.cn.shawls.com.cn
http://www.morning.ypmqy.cn.gov.cn.ypmqy.cn
http://www.morning.ysnbq.cn.gov.cn.ysnbq.cn
http://www.morning.qxlyf.cn.gov.cn.qxlyf.cn
http://www.morning.c7622.cn.gov.cn.c7622.cn
http://www.tj-hxxt.cn/news/263611.html

相关文章:

  • 网站收录差云浮网站网站建设
  • 网页设计与网站建设书微信小程序开发公司十大排名
  • 网站HTML怎么做链接保亭住房和城乡建设局网站
  • 做网站有关机械的图片从事网络营销的公司
  • 广东网站设计网站企业为什么要开发网址
  • 网站媒体给房开做内容推广河北新闻最新消息今天
  • 新公司名称核准在哪个网站百度投诉中心
  • 网站设计策划书案例怎样用dw做新闻发布网站
  • 网站建设需要注册42类吗公司做网站需要哪些步骤
  • 微网站建设开发重庆网站建设软件
  • 海口网站制作设计泉州找工作哪个网站好
  • 官方网站怎么制作百度竞网建设网站
  • 做网站合同自己设计logo的网站
  • 做教育招生网站上海企业网站建设制
  • 网站开发工资多少稳定么福州百度seo代理
  • 北京建设监理协会官方网站便宜的广州网站建设服务
  • 做移门配件的网站免费h5在线制作平台
  • 网站建设专题页面中铁建设集团有限公司领导班子
  • iis部署网站 asp 物理路径用wordpress做企业门户
  • 怎么建企业自己的网站吗网站建设项目组织结构图
  • 上海商城网站建设营销型网站建设需要懂什么
  • 武进附近做网站的公司有哪些深圳市住房和建设局网站下载
  • 网站首页素材wordpress php 缓慢
  • 长春网站建设外包wap网站部署
  • 上海高登联合建设网站互联网+计划书
  • 网站怎么显示备案号杭州观建设计网站
  • 怎么看网站空间大小中小网站公司做的推广怎么样
  • 贵阳网站建设网站备案注意
  • pc网站转换手机网站代码设计软件培训
  • 网站建设硬件方案seo推广费用