|
-
October 6th, 1999, 08:47 AM
#1
Should I further encapsulate existing classes
For example, when creating objects
from existing classes developed by others:
Class_Custom* pMyObject1 = new RefClass1;
Class_Custom* pMyObject2 = new RefClass2;
pMyObject->function1(...);
...
After using, I would need to manually delete it, say:
delete MyObject1;
delete MyObject2;
Question is should i further encapsulate these
with a higher class?
for example, to provide auto cleanup?
Thanks and regards
LWS
-
October 6th, 1999, 01:02 PM
#2
Re: Should I further encapsulate existing classes
If you want to provide auto cleanup, you should take a look at the STL auto_ptr class.
Regards,
Paul McKenzie
-
October 7th, 1999, 04:36 AM
#3
Re: Should I further encapsulate existing classes
Depending on your intention. For auto clean up in any circumstances including exceptions (except for longjmp) use auto_ptr, it kills pointers in destructors.
But if your question is how to structure your application then perhaps you should use the facade pattern meaning that you provide basic operations that these classes do in one class and then delegate work to other classes. Well it works for small objects (small number of system operations), but if your object is too large you need higher level of abstraction and then you can use the facade again...
Sincerely,
Tomaz
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|