caching const bake * relapse type
was reading adult bit c++, found essay rtti (runtime form identification):
. well, that's another theme :) - however, i stumbled on uncanny observant type_info
-class, namely ::name
-method. says: "the type_info::name
member duty advantage const char*
null-terminated twine representing human-readable name type. memory separate cached should never directly deallocated."
how exercise something yourself!? i've struggling definitely bit accurate problem mostly before, i don't wish new char
-array traveller delete, i've stranded std::string
so far.
so, effect simplicity, let's contend i wish slight advantage "hello world!"
, let's
const bake *gethellostring() const;
personally, i somehow (pseudo):
const bake *gethellostring() const
{
bake *returnval = new char[13];
strcpy("helloworld!", returnval);
relapse returnval
}
.. nonetheless meant traveller should delete[]
relapse pointer :(
thx advance
Comments
Post a Comment