当前位置:网站首页>7.new, delete, OOP, this pointer
7.new, delete, OOP, this pointer
2022-06-23 01:40:00 【For financial freedom!】
malloc and free Become C Library function
new and delete Called operator
malloc Failed to open up memory , Is the return value and nullptr The comparison ; and new Failed to open up memory , It's by throwing bad_alloc Type of exception !
int* q1 = new int[20];
int* q1 = new int20;
The difference between them is , The first one is only responsible for development without initialization , The second one will be initialized to 0
new How many kinds? ?
int* p1 = new int[20];
int* p2 = new (nothrow) int;// Don't throw exceptions
const int* p3 = new const int(40);// Open up memory for constants
// location new
int data = 0;
int* p4 = new(&data) int(50);// Assign a value to the specified memory !
OOP What are the four characteristics of language ?
abstract encapsulation / hide Inherit polymorphic
The memory size of an object is related to its members ! It has nothing to do with member functions ! The total size of the member variable is the same as the structure memory alignment calculation ! Class can define countless objects , Each object has its own member variable , But they share a set of membership methods ( function ).
How does a member function know which object it is called by ? After compiler processing , You know the :
边栏推荐
- JS - single sign on
- Nuxt - auto generate dynamic route bug
- Population standard deviation and sample standard deviation
- C. Number of Pairs-Codeforces Round #725 (Div. 3)
- The devil cold rice # 099 the devil said to travel to the West; The nature of the boss; Answer the midlife crisis again; Specialty selection
- [cmake command notes]find_ path
- Day500: keyboard line
- JS image resolution compression
- MySQL - SQL execution process
- [template] KMP
猜你喜欢

Byte order: big endian vs little endian

Lexical Sign Sequence

E-R图

崔鹏团队:万字长文梳理「稳定学习」全景图

Binary String

Wallys/DR7915-wifi6-MT7915-MT7975-2T2R-support-OpenWRT-802.11AX-supporting-MiniPCIe
![[launch] redis Series 2: data persistence to improve availability](/img/f4/5bc7ca3e17c6656e71df515182842e.png)
[launch] redis Series 2: data persistence to improve availability

How are pub and sub connected in ros1?

The devil cold rice # 099 the devil said to travel to the West; The nature of the boss; Answer the midlife crisis again; Specialty selection

2D prefix and
随机推荐
Foundation Consolidation - Flex width is content width
Install MySQL (5.7+8.0) through docker and configure master-slave replication (gtid+ enhanced semi synchronization)
[Title Fine brushing] 2023 Hesai FPGA
ERROR { err: YAMLException: end of the stream or a document separator is expected at line 6, colum
165. cat climbing
Up the Strip
Zabbix5 series - use temperature and humidity sensor to monitor the temperature and humidity of the machine room (XX)
JS prevent the PC side from copying correct links
[hdu] P7079 Pty loves lines
使用aggregation API扩展你的kubernetes API
[22 summer reconstruction 1] codeworks round 791 (Div. 2)
Do you know the memory components of MySQL InnoDB?
[hdu] p1466 calculate the number of intersections of straight lines
C# SerializableDictionary序列化/反序列化
JS to determine whether the browser has opened the console
[hdu] p2087 cut cloth strip
Using WordPress to create a MySQL based education website (learning notes 2) (technical notes 1) xampp error1045 solution
Vector 6 (inheritance)
[luogu] p1083 [noip2012 improvement group] classroom borrowing (difference)
魔王冷饭||#099 魔王说西游;老板的本质;再答中年危机;专业选择