new can be overridden

C

coder

The FAQ [16.4] states that "new is an operator that can be overridden
by a class". What does that mean and why would it be useful?

Thanks!
 
V

Victor Bazarov

coder said:
The FAQ [16.4] states that "new is an operator that can be overridden
by a class". What does that mean and why would it be useful?

You may define your own 'new' and 'new[]' operators (along with
'delete' and 'delete[]') in your class. Whenever you create
an object of that class using 'new' expression, your operator
will be called to allocate memory. You, therefore, have control
over the process of memory allocation.

Read about "custom allocators". The topic is significant enough
not to try to cover it in a newsgroup thread.

V
 
C

coder

coder said:
The FAQ [16.4] states that "new is an operator that can be overridden
by a class". What does that mean and why would it be useful?

You may define your own 'new' and 'new[]' operators (along with
'delete' and 'delete[]') in your class. Whenever you create
an object of that class using 'new' expression, your operator
will be called to allocate memory. You, therefore, have control
over the process of memory allocation.

Read about "custom allocators". The topic is significant enough
not to try to cover it in a newsgroup thread.

V

Thanks for the information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,184
Messages
2,570,978
Members
47,561
Latest member
gjsign

Latest Threads

Top