Click here to Skip to main content
15,909,437 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: compile error about auto_ptr Pin
peterchen23-Feb-08 6:47
peterchen23-Feb-08 6:47 
GeneralRe: compile error about auto_ptr Pin
George_George24-Feb-08 16:12
George_George24-Feb-08 16:12 
GeneralRe: compile error about auto_ptr Pin
peterchen24-Feb-08 20:25
peterchen24-Feb-08 20:25 
GeneralRe: compile error about auto_ptr Pin
George_George24-Feb-08 21:05
George_George24-Feb-08 21:05 
GeneralRe: compile error about auto_ptr Pin
Mark Salsbery24-Feb-08 9:14
Mark Salsbery24-Feb-08 9:14 
GeneralRe: compile error about auto_ptr Pin
George_George24-Feb-08 16:13
George_George24-Feb-08 16:13 
Generalchange const property through overloading Pin
George_George22-Feb-08 23:18
George_George22-Feb-08 23:18 
GeneralRe: change const property through overloading Pin
Shog923-Feb-08 4:45
sitebuilderShog923-Feb-08 4:45 
There's no real point to the code in your example, so of course it can't be said to be "good". However, i've used similar constructs in past, here are a couple of scenarios where they made sense:

When returning references to internal data, using a const and a non-const access method to return const and non-const references.
This is helpful when, for instance, most users of the API will hold only const references to the object implementing it, but in at least one scenario (a client that creates or modifies the object) there will be callers that hold a non-const reference and need non-const access to the internal data.

For private/protected methods: used to provide subtly different behavior to public access and mutator methods.
I was writing a wrapper class for INI access last night. Two different methods, GetValue() and SetValue(), both need to retrieve a section pointer from the data store. The Get method will not modify the section, and should fail if the section is not found, while the Set method will modify the section, creating it if it is not found. So, i added two GetSection() methods for use by the public API, one const, the other not, each implementing one of the needed behaviors.


But who is the king of all of these folks?

GeneralRe: change const property through overloading Pin
George_George24-Feb-08 16:21
George_George24-Feb-08 16:21 
GeneralRe: change const property through overloading Pin
Shog924-Feb-08 16:33
sitebuilderShog924-Feb-08 16:33 
GeneralRe: change const property through overloading Pin
George_George24-Feb-08 16:52
George_George24-Feb-08 16:52 
GeneralRogarding doubt C,C++,MFC Pin
rowdy_vc++22-Feb-08 22:42
rowdy_vc++22-Feb-08 22:42 
GeneralRe: Rogarding doubt C,C++,MFC Pin
Rajkumar R22-Feb-08 22:45
Rajkumar R22-Feb-08 22:45 
GeneralRe: Rogarding doubt C,C++,MFC Pin
rowdy_vc++22-Feb-08 22:51
rowdy_vc++22-Feb-08 22:51 
GeneralRe: Rogarding doubt C,C++,MFC PinPopular
Cranky22-Feb-08 23:03
Cranky22-Feb-08 23:03 
GeneralRe: Rogarding doubt C,C++,MFC Pin
rowdy_vc++22-Feb-08 23:05
rowdy_vc++22-Feb-08 23:05 
GeneralRe: Rogarding doubt C,C++,MFC Pin
CPallini22-Feb-08 23:14
mveCPallini22-Feb-08 23:14 
QuestionRe: Rogarding doubt C,C++,MFC Pin
Rajkumar R22-Feb-08 23:32
Rajkumar R22-Feb-08 23:32 
GeneralRe: Rogarding doubt C,C++,MFC Pin
Rajesh R Subramanian23-Feb-08 3:31
professionalRajesh R Subramanian23-Feb-08 3:31 
GeneralRe: Rogarding doubt C,C++,MFC Pin
Christian Graus23-Feb-08 12:43
protectorChristian Graus23-Feb-08 12:43 
GeneralRe: Rogarding doubt C,C++,MFC Pin
Cranky22-Feb-08 22:58
Cranky22-Feb-08 22:58 
GeneralRe: Rogarding doubt C,C++,MFC Pin
rowdy_vc++22-Feb-08 23:34
rowdy_vc++22-Feb-08 23:34 
GeneralRe: Rogarding doubt C,C++,MFC Pin
Cranky22-Feb-08 23:40
Cranky22-Feb-08 23:40 
GeneralRe: Rogarding doubt C,C++,MFC Pin
rowdy_vc++22-Feb-08 23:42
rowdy_vc++22-Feb-08 23:42 
GeneralRe: Rogarding doubt C,C++,MFC Pin
Christian Graus23-Feb-08 12:46
protectorChristian Graus23-Feb-08 12:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.