当前位置:网站首页>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指针
边栏推荐
- 微信小程序的分包加载
- Subcontracting loading of wechat applet
- 【周周有奖】云原生编程挑战赛“边缘容器”赛道邀你来战!
- Introduction to redis II: RedHat 6.5 installation and use
- Prize essay solicitation | 2022 cloud native programming challenge draft activity opens
- C # basic 4-written examination question 1
- How to modify the ID of NetApp expansion enclosure disk shelf
- [complete collection of common ADB commands and their usage (from a comprehensive summary of [wake up on Sunday)]
- 怎样搭建企业内部维基百科
- Record an error in runtime. Getruntime().Exec ("command")
猜你喜欢

H5 wechat shooting game source code

MobileViT:挑战MobileNet端侧霸主

什么是数据中台?数据中台带来了哪些价值?_光点科技

How bad can a programmer be? Nima, they are all talents

Why on earth is it not recommended to use select *?

Unity foundation 6-rotation

数据库--explain的使用

Learn about the native application management platform of rainbow cloud

JS drag and drop alert pop-up plug-in

Easynlp Chinese text and image generation model takes you to become an artist in seconds
随机推荐
1 Introduction to command mode
Lvs+keepalived high availability deployment practical application
Space shooting Lesson 13: explosion effect
How to balance security and performance in SQL?
The EMC vnx5200 fault light is on, but there is no hardware fault prompt
Unity gets which button (toggle) is selected under togglegroup
C foundation 2-encapsulation, inheritance, polymorphism
Three deletion strategies and eviction algorithm of redis
3D laser slam: Interpretation of logo-loam paper - Introduction
mfc wpf winform(工业用mfc还是qt)
C # basic 3-value type and reference type, packing and unpacking
MoCo V2:MoCo系列再升级
融合数据库生态:利用 EventBridge 构建 CDC 应用
图书馆借阅系统「建议收藏」
Unit editor details
Unity foundation 2 editor expansion
unity-shader-1
PostgreSQL数据库删库前是不是需要把所有连接断开才能删除?
Two written interview questions about regular
蓝队入门之效率工具篇