Click here to Skip to main content
15,891,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help! Pin
toxcct9-Dec-04 21:54
toxcct9-Dec-04 21:54 
QuestionHow to do oldschool graphics in win Pin
mirex9-Dec-04 11:03
mirex9-Dec-04 11:03 
AnswerRe: How to do oldschool graphics in win Pin
Andrew Walker9-Dec-04 14:57
Andrew Walker9-Dec-04 14:57 
GeneralCompare from file or Compare from memory Pin
Anonymous9-Dec-04 10:41
Anonymous9-Dec-04 10:41 
GeneralRe: Compare from file or Compare from memory Pin
gamitech9-Dec-04 11:55
gamitech9-Dec-04 11:55 
General2nd Question - const_cast and mutable Pin
Malcolm Smart9-Dec-04 10:41
Malcolm Smart9-Dec-04 10:41 
GeneralRe: 2nd Question - const_cast and mutable Pin
Jack Puppy9-Dec-04 15:29
Jack Puppy9-Dec-04 15:29 
GeneralRe: 2nd Question - const_cast and mutable Pin
Andrew Walker9-Dec-04 15:29
Andrew Walker9-Dec-04 15:29 
Angel1058 wrote:
1) Can anybody give me an example of why they ever made a member mutable? I know what mutable is but couldn't give a real life reason for using one (I am not one for finding a problem to meet a solution!).

In general this occurs when a const object (object A) needs to call a non-const method of the mutable member variable (object B), specifically in a way that doesn't change the const-ness of the object A (did you get all that? Wink | ;) ). Generally this occurs if pretty ugly situations - one example is: http://www.boost.org/doc/html/threads/faq.html#id635597[^]

From what I can remember reference counts are another example of this, the reference count still needs to be modified, even if the object is a const copy.

Angel1058 wrote:
2) const_cast - allows you to, for example, remove the constness from a pointer, but if that pointer points to a const item, you can't change the value of the item. So all you can do is change what the pointer is pointing to. Same question as above - can anybody tell my why they have ever const_casted a const pointer and pointed it elsewhere!?!

I can't think of a good example, but I would imagine something like the conversion of the pointer to something that allows read-only iteration through an array might be a possible answer.

If someone has gone to the effort of enforcing all that const-ness I'd think three times before performing the cast. In general const_cast should be avoided in the real world.


If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim;
Yours is the Earth and everything that's in it.

Rudyard Kipling

GeneralRe: 2nd Question - const_cast and mutable Pin
Henry miller10-Dec-04 6:22
Henry miller10-Dec-04 6:22 
Generalexcel automation with very hidden sheet Pin
pnpfriend9-Dec-04 10:38
pnpfriend9-Dec-04 10:38 
QuestionWhat is best Exe 2 Exe protocol? Pin
Malcolm Smart9-Dec-04 10:34
Malcolm Smart9-Dec-04 10:34 
AnswerRe: What is best Exe 2 Exe protocol? Pin
Alex Korchemniy9-Dec-04 11:05
Alex Korchemniy9-Dec-04 11:05 
AnswerRe: What is best Exe 2 Exe protocol? Pin
Renjith Ramachandran9-Dec-04 19:13
Renjith Ramachandran9-Dec-04 19:13 
AnswerRe: What is best Exe 2 Exe protocol? Pin
Henry miller10-Dec-04 6:31
Henry miller10-Dec-04 6:31 
GeneralVariable width fonts and GetTextExtent in CEdit Pin
bob169729-Dec-04 8:47
bob169729-Dec-04 8:47 
GeneralRe: Variable width fonts and GetTextExtent in CEdit Pin
bob169729-Dec-04 11:01
bob169729-Dec-04 11:01 
GeneralHTML Help window Message handling Pin
Member 15760289-Dec-04 8:44
Member 15760289-Dec-04 8:44 
Generalswap bytes in a file Pin
Anonymous9-Dec-04 8:09
Anonymous9-Dec-04 8:09 
GeneralRe: swap bytes in a file Pin
David Crow9-Dec-04 10:24
David Crow9-Dec-04 10:24 
GeneralRe: swap bytes in a file Pin
Anonymous9-Dec-04 10:29
Anonymous9-Dec-04 10:29 
GeneralSerial Communication ... problems! Pin
PPatrickFFM9-Dec-04 5:48
PPatrickFFM9-Dec-04 5:48 
GeneralRe: Serial Communication ... problems! Pin
bob169729-Dec-04 9:43
bob169729-Dec-04 9:43 
GeneralAdding controls to ActiveX project Pin
greekgoddj9-Dec-04 5:06
greekgoddj9-Dec-04 5:06 
GeneralSymbian OS Pin
Anonymous9-Dec-04 5:00
Anonymous9-Dec-04 5:00 
GeneralRe: Symbian OS Pin
toxcct9-Dec-04 21:50
toxcct9-Dec-04 21:50 

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.