Use addresses of dynamically declared objects?
I'm told I should initialize pointers to the address of the item.
i.e. char *mypoin = &someotherchar;
I've never seen the &operator used in examples of dynamiccally allocated objects. Do I need to put it there? If I don't, is it automatically set to the address?
Re: Use addresses of dynamically declared objects?
Quote:
Originally posted by Sean
I'm told I should initialize pointers to the address of the item.
i.e. char *mypoin = &someotherchar;
I've never seen the &operator used in examples of dynamiccally allocated objects. Do I need to put it there? If I don't, is it automatically set to the address?
When an object is dynamically created using new or alloc a pointer is returned. Since it is a pointer, you do not need the & to get the address of the actual data, the return pointer is the address of the actual data.