高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】should We Delete Or Free The Oddbdatabase Ob
should we delete or free the oddbdatabase object space manua
should we delete or free the oddbdatabase object space manually in an application?
in the sample project files, singledoc, packaged in the dwgdirect, i find that the document object loads a dwg file into memory by using the readfile() method, but i can't locate the clauses where the oddbdatabase object is deleted or its memory space is free. i wonder if we must to free it manually in our applications, if yes, how to do it?
in dwgdirect, smartpointers (for database it is variable of type oddbdatabaseptr) are used to store pointers to database objects. smartpointers release automatically, when go out of scope.
sincerely yours,
george udov
what does "go out of scope" mean?
code:
{
// ...
oddbdatabaseptr pdb = ...;
// scope of pdb smart pointer is from here to '}'
// ...
// some code using pdb
// ...
} // here scope of pdb ends. destructor of oddbdatabaseptr class destroys pointer to database it holds
sincerely yours,
george udov
then, if i need to use this oddbdatabase in the application where the code is out of the scope of the assigned smart pointer, how should i do?
i think you should read some book about modern c++.
for example, "modern c++ design" by andrei alexandrescu.
sincerely yours,
george udov
|