Difference between revisions of "Talk:cpp/memory/new/operator new"
From cppreference.com
< Talk:cpp
Alexis wilke (Talk | contribs) (Questioning the naming covention changing along the way.) |
Alexis wilke (Talk | contribs) (Adding some formatting.) |
||
Line 4: | Line 4: | ||
The class specific definition of the new operator says "count" as a parameter: | The class specific definition of the new operator says "count" as a parameter: | ||
+ | {{example | ||
+ | |code= | ||
void* T::operator new ( std::size_t count ); | void* T::operator new ( std::size_t count ); | ||
+ | }} | ||
However, the X structure example changes the name of the parameter to "sz" and uses it in "new(sz)". | However, the X structure example changes the name of the parameter to "sz" and uses it in "new(sz)". | ||
+ | {{example | ||
+ | |code= | ||
static void* operator new(std::size_t sz) | static void* operator new(std::size_t sz) | ||
+ | }} | ||
Alexis Wilke 20:46, 26 October 2021 (PDT) | Alexis Wilke 20:46, 26 October 2021 (PDT) |
Revision as of 19:48, 26 October 2021
Naming Convention
The class specific definition of the new operator says "count" as a parameter:
Run this code
void* T::operator new ( std::size_t count );
However, the X structure example changes the name of the parameter to "sz" and uses it in "new(sz)".
Run this code
static void* operator new(std::size_t sz)
Alexis Wilke 20:46, 26 October 2021 (PDT)