V
Vijayaraghavan Kalyanapasupathy
Hello All,
I just learnt about smart pointers. Given the advantages of using
smart-pointers, as a designer of say a List object, I can inhibit
creation of the actual objects by making its constructors and then
making the smart pointer a friend of the class (I am talking about a
specific smart pointer implementation for a specific object). Now, it
seems to me that inhibiting the use of "new" with the smart pointer
would enhance things. For example, even if I created a smart pointer
and restricted all access to via the pointer, the user can still
create smart pointer objects themselves with new right? So, unless the
user deletes these explicitly, there is still a chance of leaks right?
I am sure others must have thought about it and so must have the
language designers. My question is, is it possible to inhibit dynamic
object creation via "new" for specific classes?
thanx,
vijai.
I just learnt about smart pointers. Given the advantages of using
smart-pointers, as a designer of say a List object, I can inhibit
creation of the actual objects by making its constructors and then
making the smart pointer a friend of the class (I am talking about a
specific smart pointer implementation for a specific object). Now, it
seems to me that inhibiting the use of "new" with the smart pointer
would enhance things. For example, even if I created a smart pointer
and restricted all access to via the pointer, the user can still
create smart pointer objects themselves with new right? So, unless the
user deletes these explicitly, there is still a chance of leaks right?
I am sure others must have thought about it and so must have the
language designers. My question is, is it possible to inhibit dynamic
object creation via "new" for specific classes?
thanx,
vijai.