Click here to Skip to main content
15,914,481 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: type safe issue Pin
CPallini11-Feb-08 4:10
mveCPallini11-Feb-08 4:10 
GeneralRe: type safe issue Pin
Rajkumar R11-Feb-08 4:12
Rajkumar R11-Feb-08 4:12 
QuestionRe: type safe issue Pin
CPallini11-Feb-08 5:11
mveCPallini11-Feb-08 5:11 
GeneralRe: type safe issue [modified] Pin
Matthew Faithfull11-Feb-08 3:28
Matthew Faithfull11-Feb-08 3:28 
GeneralRe: type safe issue [modified] Pin
Rajkumar R11-Feb-08 3:52
Rajkumar R11-Feb-08 3:52 
GeneralRe: type safe issue Pin
Matthew Faithfull11-Feb-08 4:29
Matthew Faithfull11-Feb-08 4:29 
GeneralRe: type safe issue [modified] Pin
Rajkumar R11-Feb-08 4:34
Rajkumar R11-Feb-08 4:34 
GeneralRe: type safe issue Pin
Matthew Faithfull11-Feb-08 4:54
Matthew Faithfull11-Feb-08 4:54 
Rajkumar R wrote:
your example doesnot match directly


The principle is exactly the same. If a function has an [out] parameter of type CMyDocument*. In other words it takes in the address of a CMyDocument pointer, doesn't care what the value of the pointer is and overwrites it with a valid CMyDocument* pointer then it is perfectly typesafe and valid to pass that function the address of a CMyDocument1* or the address of a CMyDocument2* because these ARE CMydocument* pointers or a void* where this is a valid address for a CMyDocument* to be written into. The only restriction is that after the call you treat the pointer as a CMyDocument* not a CMyDocument1* or a CMyDocuemt2* until you have established whether it really does point ot a derived type or not. Remember all pointers are the same size and the address of a pointer is exactly the same thing as a void* anyway, slapping a type on it, which may not be the type returned, is no more or less type safe. You still have to follow the same steps on return to ensure you've got what you intended except now the code gives you a false sense of security because it looks like you're gaurenteed to get the type you asked for when you're not.

It may seem silly to labour the point but it is important not to try and impose C++ concepts unaltered onto COM. To do COM well you need to understand the changes in the way of thinking that it brings.

Nothing is exactly what it seems but everything with seems can be unpicked.

GeneralRe: type safe issue Pin
Rajkumar R11-Feb-08 5:04
Rajkumar R11-Feb-08 5:04 
GeneralRe: type safe issue Pin
Matthew Faithfull11-Feb-08 5:20
Matthew Faithfull11-Feb-08 5:20 
GeneralRe: type safe issue Pin
Rajkumar R11-Feb-08 5:25
Rajkumar R11-Feb-08 5:25 
GeneralRe: type safe issue Pin
led mike11-Feb-08 4:46
led mike11-Feb-08 4:46 
GeneralRe: type safe issue Pin
Matthew Faithfull11-Feb-08 4:58
Matthew Faithfull11-Feb-08 4:58 
GeneralRe: type safe issue Pin
Rajkumar R11-Feb-08 5:18
Rajkumar R11-Feb-08 5:18 
QuestionRe: type safe issue Pin
CPallini11-Feb-08 5:26
mveCPallini11-Feb-08 5:26 
GeneralRe: type safe issue Pin
Rajkumar R11-Feb-08 5:30
Rajkumar R11-Feb-08 5:30 
GeneralRe: type safe issue Pin
CPallini11-Feb-08 5:35
mveCPallini11-Feb-08 5:35 
GeneralRe: type safe issue Pin
Rajkumar R11-Feb-08 5:42
Rajkumar R11-Feb-08 5:42 
GeneralRe: type safe issue Pin
CPallini11-Feb-08 10:39
mveCPallini11-Feb-08 10:39 
GeneralRe: type safe issue Pin
Rajkumar R11-Feb-08 16:18
Rajkumar R11-Feb-08 16:18 
GeneralRe: type safe issue Pin
Matthew Faithfull11-Feb-08 6:04
Matthew Faithfull11-Feb-08 6:04 
GeneralRe: type safe issue Pin
Rajkumar R11-Feb-08 16:29
Rajkumar R11-Feb-08 16:29 
GeneralRe: type safe issue Pin
George_George12-Feb-08 2:21
George_George12-Feb-08 2:21 
GeneralRe: type safe issue Pin
Rajkumar R12-Feb-08 2:44
Rajkumar R12-Feb-08 2:44 
GeneralRe: type safe issue Pin
George_George12-Feb-08 2:57
George_George12-Feb-08 2:57 

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.