主页
论坛
新帖
最新消息
新帖
最新动态
制作互助群
登录
注册
Toggle sidebar
Toggle sidebar
菜单
安装应用
安装
回复主题
【进站必读】宝可饭堂社区全局规定v1.10
关于坚决维护同人创作社群秩序与共识的公告
论坛
独立开发
进阶教程
【TA】【ESS】07 类的多态性
禁用JavaScript。为了获得更好的体验,请在运行之前启用浏览器中的JavaScript。
您正在使用一款已经过时的浏览器!部分功能不能正常使用。
请尝试升级或使用
其他浏览器
。
信息
<blockquote data-quote="TAAAAAAA" data-source="post: 2358" data-attributes="member: 2783"><p><u>Adding and overwriting methods 增加和覆盖方法</u></p><p></p><p>You can open and close a class whenever and wherever you want without any issues. If we wanted, we could define a method like this:</p><p></p><p>类可以随时打开和关闭,我们也可以随时在类中增加新的方法,请看下面的例子:</p><p></p><p></p><p>It opens and closes the class, opens it again, adds a method, closes, and opens and closes again. It doesn’t actually modify anything. The only time opening and closing directly may be useful is if the class isn’t actually defined yet in the first place.</p><p></p><p>在上面的例子中,类先是打开,接着关闭,接着打开,接着新增加了一个方法,接着关闭,接着又打开,接着又关闭。</p><p>如果我们仅仅只是打开和关闭它的话,实际上不会产生任何影响。</p><p>唯一有影响的是第二次打开和关闭的时候,我们为这个类新加了一个实例方法。</p><p></p><p>If you add a method that has the same name as a method that already exists, it will be <strong>overwritten</strong>. All calls to that will then call the new method.</p><p></p><p>但是,如果你新定义的方法是这个类中已有的方法的话,那么已有的方法就会失效,也就是说,因为名字相同,所以已有的方法被覆盖了。</p><p>也就是说,在同一个类中,同名的方法只能有一个,后面的同名方法会覆盖之前的同名方法。</p><p>我们来看下面的这个例子:</p><p></p><p></p><p>You can also add methods to already existing classes, or overwrite methods that already exist (whether or not that’s a good idea is a different story, but it’s possible).</p><p></p><p>下面这个例子不知道是什么鬼,很奇怪,但是原文就是这样的。</p></blockquote><p></p>
[QUOTE="TAAAAAAA, post: 2358, member: 2783"] [U]Adding and overwriting methods 增加和覆盖方法[/U] You can open and close a class whenever and wherever you want without any issues. If we wanted, we could define a method like this: 类可以随时打开和关闭,我们也可以随时在类中增加新的方法,请看下面的例子: It opens and closes the class, opens it again, adds a method, closes, and opens and closes again. It doesn’t actually modify anything. The only time opening and closing directly may be useful is if the class isn’t actually defined yet in the first place. 在上面的例子中,类先是打开,接着关闭,接着打开,接着新增加了一个方法,接着关闭,接着又打开,接着又关闭。 如果我们仅仅只是打开和关闭它的话,实际上不会产生任何影响。 唯一有影响的是第二次打开和关闭的时候,我们为这个类新加了一个实例方法。 If you add a method that has the same name as a method that already exists, it will be [B]overwritten[/B]. All calls to that will then call the new method. 但是,如果你新定义的方法是这个类中已有的方法的话,那么已有的方法就会失效,也就是说,因为名字相同,所以已有的方法被覆盖了。 也就是说,在同一个类中,同名的方法只能有一个,后面的同名方法会覆盖之前的同名方法。 我们来看下面的这个例子: You can also add methods to already existing classes, or overwrite methods that already exist (whether or not that’s a good idea is a different story, but it’s possible). 下面这个例子不知道是什么鬼,很奇怪,但是原文就是这样的。 [/QUOTE]
验证
使用必应搜索是否可以搜到本网站?
回复帖子
最新帖子
○ ESS19-20
【游戏引擎】构造/地震引擎简介
最新更新:TAAAAAAA
今天 18:29
入门教程
ESS
【同人游戏】口袋妖怪 地震 0.4.9
最新更新:TAAAAAAA
昨天 14:25
独立同人
✓ ESS20-21
如何制作一个隐藏性格,并令其无法在野生宝可梦身上出现?
最新更新:TAAAAAAA
昨天 14:24
开发问题
教程攻略
应该是这样
最新更新:幽冥魔帝
2026/07/07
同人改版讨论
mGBA西班牙火箭队五周目汉化版怎么调出内置修改器啊
最新更新:TAAAAAAA
2026/07/06
同人改版讨论
论坛统计
主题
611
消息
2,722
成员
3,849
最新成员
Contrary
联系我们
QQ
2201858342
邮箱
pokefans@qq.com
论坛
独立开发
进阶教程
【TA】【ESS】07 类的多态性
顶部