Re: pointer conventions
- From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx>
- Date: Fri, 24 Feb 2006 15:23:10 -0800
"PDHB" <PDHB@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8288EC0D-224D-4DBA-BAB4-61938AA6569E@xxxxxxxxxxxxxxxx
I haven't used native C++ much, and need to know a bit about conventions
foe
managing native pointers. I generally try to copy the contents of a
pointer
to member variables rather than passing a reference. This way I know I can
always delete the pointer in the destructor of the owning object. But when
it
is ncessary to store a reference to an external native pointer, such as
when
it is a member of the managed wrapper I use to access the functionality of
the native object it points to, is there any standard convention to stop
someone from deleting that pointer in the destructor later on? Also, is
there
a standard way to communicate to a later developer not to assume the
pointer
is being copied in a constructor or an accessor, as opposed to having its
reference stored, such as in either the name of the parameter, or in
comments?
One convention: documentation. That's all you've got, and is the main
reason why pointer erros are so prevalent in C. C++ mitigates it somewhat
since you can hide pointers inside classes that always handle the pointer
correctly.
-cd
.
- Prev by Date: Re: Please help me, i got message Assertation falure line 47 _block_type_is_valid(phead->nBlockType) with following code
- Next by Date: Re: Overwrite Pre-existing DLL
- Previous by thread: Window Subclassing?
- Next by thread: Re: pointer conventions
- Index(es):
Relevant Pages
|