Re: pointer conventions

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"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


.



Relevant Pages

  • Re: Question on LSP
    ... Sure, the developer must keep track of which type has been assigned to each pointer to manage complexity in creating the design, which is why the 'T' is in T*. ... Subtyping is a relation which does not ... Those object types are completely orthogonal to the semantics of being an object reference. ... aggregate references, is the aggregate of referenced objects or target ...
    (comp.object)
  • Re: Question on LSP
    ... Because construction paradigms have different goals. ... But that has nothing to do with what a pointer type ... But that does not mean that the semantics of an object reference is ... aggregate references, is the aggregate of referenced objects or target ...
    (comp.object)
  • Re: Question on LSP
    ... equivalent addresses in the same context. ... Note that the language allows us to use a name like 'T' on the reference as a mnemonic so that the developer can keep track of what is happening with the indirection. ... Modern languages have proper pointer types. ...
    (comp.object)
  • Re: Nothing Keyword Destories Objects rather than just resetting the variable to an empty variable
    ... there is no difference between using ByVal or ByRef. ... as the C1 pointer was the sole reference to the class object. ... Yes, an object variable is a pointer to an object, but that is the only ... the keyword "NOTHING" should only destroy the ...
    (microsoft.public.excel.programming)
  • Re: How java passes object references?
    ... to think of them as being a specific location in a larger block of memory ... Whether a language passes by reference or by value, ... is a pointer pointing at the memory block. ... So when allocating local memory for o, it would simply allocate a ...
    (comp.lang.java.programmer)