当前位置:网站首页>Lesson 23 temporary objects
Lesson 23 temporary objects
2022-04-23 12:05:00 【Night rain】
Lesson 23 Temporary objects
List of articles
One 、 Example
class test{
private:
int i;
public:
test(int j)
{
i = j;
}
test()
{
test(0); // Here a temporary object is generated
}
void printfi(void)
{
printf("%d", i);
};
}
int main(char* argc, char** argv)
{
test t;
t.printfi();
return 0;
}
The output value of the above function is not 0, Why is that ?
A constructor is a special function , Calling the constructor directly will produce a temporary object , The declaration cycle of a temporary object is only the time of one statement , The scope of a temporary object is intended to be in a statement . The temporary object is C++ Notable gray areas in
The reason for the above phenomenon is the introduction of temporary objects .
- modern C++ The compiler does not affect the final execution result , We will try our best to reduce the generation of temporary objects
Two 、 Summary
-
Calling the constructor directly will produce a temporary object
-
Temporary objects are the bottleneck of performance , It's also bug One of the sources of
-
modern C++ The compiler will try to avoid temporary objects
The premise of avoiding is that it does not affect the execution result
-
In the process of actual project development, it is necessary to avoid temporary objects
版权声明
本文为[Night rain]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231155356085.html
边栏推荐
- 第四章 为IM 启用填充对象之在NO INMEMORY表上指定INMEMORY列属性:示例(IM-4.4 第四部分)
- A detailed explanation of head pose estimation [collection of good articles]
- Design and practice of the smallest short website system in the whole network
- Sigmoid function of activation function
- 数组---
- Force buckle - 70 climb stairs
- 编程辅助工具推荐:图片工具snipaste
- IDEA 中 .properties文件的中文显示乱码问题的解决办法
- Chapter 4 specifies the attribute of the inmemory column on the no inmemory table for im enabled filling objects: examples (Part IV of im-4.4)
- The database navigator uses the default MySQL connection prompt: the server time zone value 'Ö Ð¹ ú±ê ×¼ ʱ ¼ ä’ is unrecognized or repres
猜你喜欢

Force buckle - 70 climb stairs

外包干了五年,废了...

Idea code quality specification plug-in sonarlint
![A detailed explanation of head pose estimation [collection of good articles]](/img/59/6ac8692b0dbd0218bb512c5eac3124.png)
A detailed explanation of head pose estimation [collection of good articles]

魔域来了H5游戏详细图文架设教程

亿级流量架构,服务器如何扩容?写得太好了!

IDEA 数据库插件Database Navigator 插件

1. Construction of electron development environment

Nacos Foundation (9): Nacos configuration management from single architecture to microservices

Nacos Foundation (6): Nacos configuration management model
随机推荐
1. Construction of electron development environment
5个免费音频素材网站,建议收藏
Share two practical shell scripts
Resolution due to AMD not found_ ags_ x64. DLL, unable to continue code execution. Reinstallation of the program may solve this problem, Forza horizon 5
Nacos Foundation (7): Configuration Management
PSCP basic usage
异步时钟亚稳态 的解决方案——多bit信号
面了一圈,整理了这套面试题。。
画结果图推荐网址
Master slave replication configuration of MySQL
Tensorflow common functions
获取钉钉考勤机打卡记录
Symmetric encryption, certificate encryption
Next. JS static data generation and server-side rendering
智能多线弹性云增加独立的IP地址,如何实现多线功能?
WIN10 启动后花屏
How to expand the capacity of the server in the 100 million level traffic architecture? Well written!
Relu function of activation function
kettle复制记录到结果和从结果获取记录使用
Yunna | fixed assets inventory supports multiple inventory methods (asset inventory)