C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Style question, when to use pointers

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Karl
Guest





PostPosted: Tue Dec 30, 2003 5:54 pm    Post subject: Style question, when to use pointers Reply with quote




Generally when do you use pointers rather than stack variables?
Back to top
Victor Bazarov
Guest





PostPosted: Tue Dec 30, 2003 6:04 pm    Post subject: Re: Style question, when to use pointers Reply with quote



"Karl" <no@emailprovided> wrote...
Quote:

Generally when do you use pointers rather than stack variables?

When I need the object to survive across functions (especially
upon return), with minimal overhead. When I need polymorphic
behaviour (although in some situations references are OK).



Back to top
Andrew Koenig
Guest





PostPosted: Tue Dec 30, 2003 6:29 pm    Post subject: Re: Style question, when to use pointers Reply with quote



Quote:
Generally when do you use pointers rather than stack variables?

If you can use

an iterator referring to an element of a standard-library container, or
a local variable (what you are referring to as a stack variable), or
a reference,

then you shouldn't use a pointer unless you can clearly articulate a reason
why a pointer is superior to any of these alternatives.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.