c++ - Overriding operator -
anybody me constructor overriding..
i have
void operator delete(void*) {} void operator delete(void* p, void*) {}
in class.. looks overloading(same function name , return type different parameter list) overriding .. how overriding..
anyone explain me these 2 lines function.
void operator delete(void*) {} void operator delete(void* p, void*) {}
these custom deallocation functions. deallocation function called via delete
expression. e.g.
yourclass* p = new yourclass(); // allocates memory & calls constructor // ... whatever, delete p; // calls destructor & deallocates memory
for class delete
expression in last line above first call destructor, , call single void*
argument deallocation function class defines, first of 2 functions, if deallocation accessible.
however, might deallocation function declared private
or protected
, purpose of making inaccessible. in first case delete
expression outside class' own code won't compile (inaccessible deallocation function). , if may whole point -- or, don't surprised if there's no point @ all.
by way, have @ this tutorial. it's apparently least bad free introduction c++ on net. bruce eckel's e-book "thinking in c++" free, has errors , misinformation (it used other way around though, tutorial @ cplusplus.com used bad, once).
cheers & hth.,
Comments
Post a Comment