Click here to Skip to main content
15,886,799 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Is it ok to use uninitialized pointer? Pin
Cedric Moonen4-Aug-10 21:07
Cedric Moonen4-Aug-10 21:07 
GeneralRe: Is it ok to use uninitialized pointer? Pin
CPallini4-Aug-10 21:15
mveCPallini4-Aug-10 21:15 
AnswerRe: Is it ok to use uninitialized pointer? [modified] Pin
bleedingfingers4-Aug-10 21:19
bleedingfingers4-Aug-10 21:19 
AnswerRe: Is it ok to use uninitialized pointer? Pin
Sameerkumar Namdeo4-Aug-10 23:17
Sameerkumar Namdeo4-Aug-10 23:17 
AnswerRe: Is it ok to use uninitialized pointer? Pin
MuraliKrishnaP5-Aug-10 9:44
MuraliKrishnaP5-Aug-10 9:44 
Questionwhy const pointer is NOT const? how to solve the problem? Pin
includeh104-Aug-10 13:12
includeh104-Aug-10 13:12 
AnswerRe: why const pointer is NOT const? how to solve the problem? PinPopular
KingsGambit4-Aug-10 17:02
KingsGambit4-Aug-10 17:02 
AnswerRe: why const pointer is NOT const? how to solve the problem? Pin
Aescleal5-Aug-10 0:02
Aescleal5-Aug-10 0:02 
Most compilers can detect use of uninitialised pointers. Try cranking the warning level up and flagging warnings as errors (/W4 /WX on VC++ and gcc IIRC).

If you want to make sure that pointers are initialised before use there is a solution - don't use pointers. There's really no reason to use raw pointers these days (apart from compatibility with code written in C). Pointers have three uses and there's a better solution for all of them:

- marking ownership - instead use a smart pointer, even std::auto_ptr is usable with a few caveats

- iteration - use containers and use iterators from the containers

- referring to other objects - use references if the object can't be rebound, a smart pointer if it can.

Now onto the const bit... You've read the type wrong. What you've got isn't a "constant pointer" but a "pointer to a constant object". C and C++ have slightly strange declarators in that you don't read them left to right but identifier outwards in precedence order.

Cheers,

Ash
QuestionHow to get physical memory size available to a process? Pin
Code-o-mat4-Aug-10 11:25
Code-o-mat4-Aug-10 11:25 
QuestionRe: How to get physical memory size available to a process? Pin
norish5-Aug-10 4:38
norish5-Aug-10 4:38 
AnswerRe: How to get physical memory size available to a process? Pin
Code-o-mat5-Aug-10 4:54
Code-o-mat5-Aug-10 4:54 
GeneralRe: How to get physical memory size available to a process? Pin
norish5-Aug-10 19:48
norish5-Aug-10 19:48 
GeneralRe: How to get physical memory size available to a process? Pin
Code-o-mat5-Aug-10 21:55
Code-o-mat5-Aug-10 21:55 
QuestionGet/Kill focus in MFC Pin
geoyar4-Aug-10 9:23
professionalgeoyar4-Aug-10 9:23 
AnswerRe: Get/Kill focus in MFC Pin
Code-o-mat4-Aug-10 11:15
Code-o-mat4-Aug-10 11:15 
GeneralRe: Get/Kill focus in MFC Pin
geoyar5-Aug-10 12:19
professionalgeoyar5-Aug-10 12:19 
GeneralRe: Get/Kill focus in MFC Pin
Code-o-mat5-Aug-10 21:52
Code-o-mat5-Aug-10 21:52 
GeneralRe: Get/Kill focus in MFC Pin
geoyar6-Aug-10 7:29
professionalgeoyar6-Aug-10 7:29 
GeneralRe: Get/Kill focus in MFC Pin
Code-o-mat6-Aug-10 8:35
Code-o-mat6-Aug-10 8:35 
GeneralRe: Get/Kill focus in MFC Pin
geoyar6-Aug-10 10:01
professionalgeoyar6-Aug-10 10:01 
GeneralRe: Get/Kill focus in MFC Pin
Code-o-mat6-Aug-10 10:06
Code-o-mat6-Aug-10 10:06 
GeneralRe: Get/Kill focus in MFC Pin
geoyar6-Aug-10 11:31
professionalgeoyar6-Aug-10 11:31 
GeneralRe: Get/Kill focus in MFC Pin
Code-o-mat6-Aug-10 11:36
Code-o-mat6-Aug-10 11:36 
GeneralRe: Get/Kill focus in MFC Pin
geoyar6-Aug-10 15:41
professionalgeoyar6-Aug-10 15:41 
GeneralRe: Get/Kill focus in MFC Pin
geoyar6-Aug-10 16:08
professionalgeoyar6-Aug-10 16:08 

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.