About New NEW in C ++

zhaozj2021-02-16  75

In the C Primer, the new operation of the new operation:

T * t = new t (); // Assign a pointer to a single T object

T * t = new T [8]; // Assign an array of specific dimensions and types

Don't consider an array first, for a low version, we define two objects:

T1 * t1 = new T1 (); // give T1 an address value, is this?

T2 * t2 = new t2 (); // give T2 an address value, is this?

It should be said that T1, T2 is two pointer variables, and they have no difference, then

T1-> memoft1 (); // -> What is the MEMEOFT1?

It seems to be this:

The New operator is equivalent to such a function:

NEW operation function

{

Assign memory to the object;

Mark the first address of the object member in some way; // This -> can you find it!

Return first address;

}

HEHE, RIGHT? I want to know! it is my girl !!

转载请注明原文地址:https://www.9cbs.com/read-13869.html

New Post(0)