T
Tito
I have two questions about the singletons' chapter of Alexei Alexandrescu's
"C++ Modern Design".
1. In the beginning of the chapter Alexei states that a "singleton" class
implementation made of static member functions has the problem that the
functions are not virtual, so that you have to touch the class' code in
order to change the behaviour. But, how is a singleton meant to be inherited
from? Is not the concrete class of the unique instance already hardcoded in
the singleton's implementation?
2. We he presents his SetLongevity utility, he uses realloc instead of
new/delete, arguing that if not doing so, the data structure that
SetLongevity maintains would suffer of the same longevity problems as other
singletons. I do not understand that, because they are cleanly deleted on
atexit(). Can someone explain it to me?
Thanks,
Tito
"C++ Modern Design".
1. In the beginning of the chapter Alexei states that a "singleton" class
implementation made of static member functions has the problem that the
functions are not virtual, so that you have to touch the class' code in
order to change the behaviour. But, how is a singleton meant to be inherited
from? Is not the concrete class of the unique instance already hardcoded in
the singleton's implementation?
2. We he presents his SetLongevity utility, he uses realloc instead of
new/delete, arguing that if not doing so, the data structure that
SetLongevity maintains would suffer of the same longevity problems as other
singletons. I do not understand that, because they are cleanly deleted on
atexit(). Can someone explain it to me?
Thanks,
Tito