当前位置:网站首页>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 :
边栏推荐
- [cmake command notes]find_ path
- LINQ 查詢
- Overview of visual object detection technology based on deep learning
- Why can't I access object properties in a for in loop in an object array
- Webdriver and selenium Usage Summary
- C. Number of Pairs-Codeforces Round #725 (Div. 3)
- [hdu] P6964 I love counting
- Huawei cloud recruits partners in the field of industrial intelligence to provide strong support + commercial realization
- Flink synchronizes MySQL data to es
- Wallys/DR7915-wifi6-MT7915-MT7975-2T2R-support-OpenWRT-802.11AX-supporting-MiniPCIe
猜你喜欢

MySQL - SQL execution process

Constexpr keyword

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

Network module packaging

MySQL-Seconds_ behind_ Master accuracy error

Huawei cloud recruits partners in the field of industrial intelligence to provide strong support + commercial realization

Development status of full color LED display

Steps to implement a container global component

Debian10 LVM logical volumes

Foundation Consolidation - Flex width is content width
随机推荐
Binary String
Use of higher order functions
Detailed explanation of clip attribute parameters
[hdu] p1466 calculate the number of intersections of straight lines
C# SerializableDictionary序列化/反序列化
Thread local storage understanding
Install MySQL (5.7+8.0) through docker and configure master-slave replication (gtid+ enhanced semi synchronization)
A hundred lines of code to realize reliable delay queue based on redis
Explain the startup process of opengauss multithreading architecture in detail
Extend your kubernetes API using the aggregation API
Js--- SVG to png
时间复杂度
LINQ 查詢
Extend your kubernetes API using the aggregation API
Vector 2 (friend and copy construction)
Use elk to save syslog, NetFlow logs and audit network interface traffic
Knowledge point learning
It's still like this
Overview of visual object detection technology based on deep learning
Google benchmark user manual and examples