new 初始化:括號內加初始值
int *pi = new int (6) // C++98
struct where {double x; double y; double z};
where * one = new where {2.5, 5.3, 7.2}; // C++11
以下為定位 new:
包含頭檔案 new
#include<new>
需指定地址引數
char buffer[50]; char *p = new (buffer) char[50]; int *after = new int; int *q = new(after) int;
- 定位new也可初始化
- 雖然delete可與常規new運算子配合使用,但不能與定位new運算子配合使用
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/24311.html
標籤:C++
上一篇:C++基礎之常量與指標
下一篇:C++ 一些術語
