Click here to Skip to main content
15,912,400 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: WIN32 API to find out color monitor v/s monochrome monitor Pin
Blake Miller20-Jun-06 9:15
Blake Miller20-Jun-06 9:15 
QuestionModular app design Pin
Anton Afanasyev15-Jun-06 15:25
Anton Afanasyev15-Jun-06 15:25 
AnswerRe: Modular app design Pin
Cedric Moonen15-Jun-06 20:25
Cedric Moonen15-Jun-06 20:25 
QuestionRe: Modular app design Pin
Anton Afanasyev15-Jun-06 21:42
Anton Afanasyev15-Jun-06 21:42 
AnswerRe: Modular app design Pin
Cedric Moonen15-Jun-06 22:28
Cedric Moonen15-Jun-06 22:28 
GeneralRe: Modular app design Pin
Anton Afanasyev16-Jun-06 6:15
Anton Afanasyev16-Jun-06 6:15 
GeneralRe: Modular app design Pin
Cedric Moonen16-Jun-06 9:32
Cedric Moonen16-Jun-06 9:32 
QuestionCasting pointer to pointer of class [modified] Pin
Andre xxxxxxx15-Jun-06 14:31
Andre xxxxxxx15-Jun-06 14:31 
Hi,

I have a class that wraps a COM object and has only 1 member, a pointer to the COM object (interface pointer) and several methods. It could also be any other pointer.

The size of an instance of this class is 4 bytes, there are no virtual methods or other members.

class CIntPtr<br />
{<br />
public:<br />
  void AddOne () { (*m_pMyInt)++; }<br />
  int *m_pMyInt;<br />
};


Is it now safe to cast an int* to an CIntPtr*?

int myInt = 0;<br />
int *myIntPtr = &myInt;<br />
<br />
CIntPtr *myIntWrapper = (CIntPtr *) &myIntPtr;<br />
myIntWrapper->AddOne ();



The code runs fine and I don't see any problem with this. Actually I would even say it is better than creating a new object and calling the constructor which makes a copy of the pointer. There is also no additional object that needs to be deleted.

But maybe this causes problems I'm not aware of.
QuestionRe: Casting pointer to pointer of class [modified] Pin
#hackC++15-Jun-06 14:56
#hackC++15-Jun-06 14:56 
AnswerRe: Casting pointer to pointer of class [modified] Pin
Andre xxxxxxx15-Jun-06 15:03
Andre xxxxxxx15-Jun-06 15:03 
AnswerRe: Casting pointer to pointer of class Pin
Michael Dunn15-Jun-06 16:13
sitebuilderMichael Dunn15-Jun-06 16:13 
GeneralRe: Casting pointer to pointer of class Pin
Stephen Hewitt15-Jun-06 18:23
Stephen Hewitt15-Jun-06 18:23 
GeneralRe: Casting pointer to pointer of class Pin
Michael Dunn15-Jun-06 20:41
sitebuilderMichael Dunn15-Jun-06 20:41 
GeneralRe: Casting pointer to pointer of class [modified] Pin
Stephen Hewitt15-Jun-06 20:46
Stephen Hewitt15-Jun-06 20:46 
AnswerRe: Casting pointer to pointer of class [modified] Pin
Arvind Bharti15-Jun-06 17:10
Arvind Bharti15-Jun-06 17:10 
AnswerRe: Casting pointer to pointer of class [modified] Pin
Stephen Hewitt15-Jun-06 18:40
Stephen Hewitt15-Jun-06 18:40 
QuestionLayered Window Question - UpdateLayeredWindow() API [modified] Pin
JeanneBucks15-Jun-06 13:17
JeanneBucks15-Jun-06 13:17 
QuestionHard question about Critical section - in C++ .... Pin
Yanshof15-Jun-06 10:16
Yanshof15-Jun-06 10:16 
AnswerRe: Hard question about Critical section - in C++ .... Pin
Eric Dahlvang15-Jun-06 10:40
Eric Dahlvang15-Jun-06 10:40 
AnswerRe: Hard question about Critical section - in C++ .... Pin
David Crow15-Jun-06 10:46
David Crow15-Jun-06 10:46 
GeneralRe: Hard question - still without answer Pin
Yanshof15-Jun-06 11:40
Yanshof15-Jun-06 11:40 
GeneralRe: Hard question - still without answer Pin
David Crow16-Jun-06 2:33
David Crow16-Jun-06 2:33 
AnswerRe: Hard question about Critical section - in C++ .... Pin
Jörgen Sigvardsson15-Jun-06 12:23
Jörgen Sigvardsson15-Jun-06 12:23 
AnswerRe: Hard question about Critical section - in C++ .... Pin
Arvind Bharti15-Jun-06 17:20
Arvind Bharti15-Jun-06 17:20 
GeneralRe: Hard question about Critical section - in C++ .... Pin
Rick York15-Jun-06 20:20
mveRick York15-Jun-06 20:20 

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.