|
Prev: return value
Next: problem using delphi dll in vc++
From: Carmen Sei on 16 Apr 2008 21:23 I found in C++ a type is typedef several times and alot of time, I need to dig further to see the original type. like LPDWORD - it's a strange type, but when i dig further, i see it's a (DWORD *) =========== typedef DWORD near *PDWORD; typedef DWORD far *LPDWORD; =========== i feel that creating new type in C++ by using "typedef" is similar to inheritance in Java - where alot of time I need to dig further to found the "PARENT" type of an object hierarchy.
From: Doug Harrison [MVP] on 16 Apr 2008 21:48 On Wed, 16 Apr 2008 18:23:10 -0700, Carmen Sei <fatwallet951(a)yahoo.com> wrote: > I found in C++ a type is typedef several times and alot of time, I >need to dig further to see the original type. > >like LPDWORD - it's a strange type, but when i dig further, i see it's >a (DWORD *) > >=========== >typedef DWORD near *PDWORD; >typedef DWORD far *LPDWORD; > >=========== >i feel that creating new type in C++ by using "typedef" is similar to >inheritance in Java - The C++ typedef keyword is used to create synonyms for existing types. It's got nothing to do with inheritance. >where alot of time I need to dig further to found the "PARENT" type of >an object hierarchy. True, you're digging, but for different things. -- Doug Harrison Visual C++ MVP
From: Carmen Sei on 17 Apr 2008 01:05 why create some many synonyms of existing types. that create great confusion like - typedef DWORD far *LPDWORD; what LPDWORD is? not until u need to dig further to find out it's DWORD*. > >The C++ typedef keyword is used to create synonyms for existing types. It's >got nothing to do with inheritance. > >>where alot of time I need to dig further to found the "PARENT" type of >>an object hierarchy. > >True, you're digging, but for different things.
From: Ulrich Eckhardt on 17 Apr 2008 03:42 Carmen Sei wrote: > why create some many synonyms of existing types. > > that create great confusion like - > typedef DWORD far *LPDWORD; > > what LPDWORD is? not until u need to dig further to find out it's > DWORD*. In fact it's not, or rather it used not to be. The point is that 'L' means long and 'P' means pointer. In ye olde memorey modell, there used to be a distinction between near and far pointers, which had to do with segmented memory. So, there, you always had to specify which type of pointer you meant, which caused quite some typing overhead, so people invented those shortcuts. The 'L' is nowadays obsolete, and a simple PDWORD should also work, but often you still see the form with the 'L'. BTW: another often-used one is 'C' which means 'const'. Please don't top-post. Uli -- C++ FAQ: http://parashift.com/c++-faq-lite Sator Laser GmbH Geschäftsführer: Michael Wöhrmann, Amtsgericht Hamburg HR B62 932
From: Jonathan Wood on 18 Apr 2008 12:17 A lot of those relate to creating various definitions for compatibility with older code, and in some cases new libraries. For example, under the 16-bit compiler, far and near were keywords. Now they're defines that serve no purpose other than to allow code that uses them to still compile. It's just to make things easier in some cases. That's all. -- Jonathan Wood SoftCircuits Programming http://www.softcircuits.com "Carmen Sei" <fatwallet951(a)yahoo.com> wrote in message news:ohmd049il0dqjtr6tomcrep16mj5hqlivt(a)4ax.com... > why create some many synonyms of existing types. > > that create great confusion like - > typedef DWORD far *LPDWORD; > > what LPDWORD is? not until u need to dig further to find out it's > DWORD*. > > > > >> >>The C++ typedef keyword is used to create synonyms for existing types. >>It's >>got nothing to do with inheritance. >> >>>where alot of time I need to dig further to found the "PARENT" type of >>>an object hierarchy. >> >>True, you're digging, but for different things.
|
Pages: 1 Prev: return value Next: problem using delphi dll in vc++ |