当前位置:网站首页>4.1 Member的各种调用方式
4.1 Member的各种调用方式
2022-07-28 19:06:00 【CCSUZB】
Nonstatic Member Functions(非静态成员函数)
考虑如下代码:
float magnitude3d(const Point3d *_this) {
};
float Point3d::magnitude3d() const {
};
选择 member function
不应该带来什么额外负担,因为编译器内部已经将“member函数实例”转换为对等的“nonmember函数实例”
名称的特殊处理
一般而言,member
的名称前面会被加上class
名称,形成独一无二的命名:
class Bar {
public : int ival;}
其中ival
有可能变成这样:ival_3Bar
;为什么编译器要这么做?请考虑如下派生操作:
class Foo : public Bar {
public : int ival;};
Foo
对象内部结合了base class
和derived class
两者:
class Foo {
public:
int ival_3Bar;
int ivla_3Foo;
}
不管你要处理哪个ival
,通过"name manglin",都可以绝对清楚指出来。
virtual Member Functions(虚拟成员函数)
如果normalize()
是一个virutal member function
,那么以下的调用:
ptr->normalize();
将会被内部转化为:
(*ptr->vptr[1])(ptr);
- vptr表示由编译器产生的指针,指向
virtual table
- 1是
virtual table slot
的索引数值,关联到nomalize
函数 - 第二个
ptr
表示this
指针
边栏推荐
- EfficientFormer:轻量化ViT Backbone
- [工具类] Map的util包, 常用 实体类转化为map等操作
- What is data center? What value does the data center bring_ Light spot technology
- 使用ORDER BY 排序
- Unity foundation 1 - event execution sequence, custom events
- Record an error in runtime. Getruntime().Exec ("command")
- C language final review questions
- How can enterprises successfully complete cloud migration?
- [complete collection of common ADB commands and their usage (from a comprehensive summary of [wake up on Sunday)]
- C foundation 8-reflection and dependency injection
猜你喜欢
How can enterprises successfully complete cloud migration?
PL515 SOT23-5 单/双口 USB 充电协议端口控制器 百盛电子代理商
How bad can a programmer be? Nima, they are all talents
云原生编程挑战赛火热开赛,51 万奖金等你来挑战!
What is data center? What value does the data center bring_ Light spot technology
"When you are no longer a programmer, many things will get out of control" -- talk to SUSE CTO, the world's largest independent open source company
EasyNLP中文文图生成模型带你秒变艺术家
H5 wechat shooting game source code
Redis 3.0 source code analysis - data structure and object SDS list Dict
Laser slam:logo-loam --- code compilation, installation and gazebo test
随机推荐
How to modify the ID of NetApp expansion enclosure disk shelf
MoCo V3:视觉自监督迎来Transformer
十七年运维老兵万字长文讲透优维低代码~
MySQL修改端口号(修改mysql的端口号会有问题吗)
远光软件获得阿里云产品生态集成认证,携手阿里云共建新合作
H5 wechat shooting game source code
Explain the life cycle function in unity in detail
Introduction to redis II: RedHat 6.5 installation and use
[工具类] Map的util包, 常用 实体类转化为map等操作
Introduction to redis I: redis practical reading notes
Ask if you don't understand, and quickly become an advanced player of container service!
How to use redis to realize things and locks?
C # basic 3-value type and reference type, packing and unpacking
Space shooting lesson 09: elf animation
记一次Runtime.getRuntime().exce(“command“)报错
Unity gets which button (toggle) is selected under togglegroup
Why on earth is it not recommended to use select *?
Read the recent trends of okaleido tiger and tap the value and potential behind it
Fragment中使用ViewPager滑动浏览页面
图书馆借阅系统「建议收藏」