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.

Re: typedef vs inheritance by Doug

Doug
Wed Apr 16 20:48:25 CDT 2008

On Wed, 16 Apr 2008 18:23:10 -0700, Carmen Sei <fatwallet951@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

Re: typedef vs inheritance by Carmen

Carmen
Thu Apr 17 00:05:17 CDT 2008

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.

Re: typedef vs inheritance by Ulrich

Ulrich
Thu Apr 17 02:42:22 CDT 2008

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

Re: typedef vs inheritance by Jonathan

Jonathan
Fri Apr 18 11:17:21 CDT 2008

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@yahoo.com> wrote in message
news:ohmd049il0dqjtr6tomcrep16mj5hqlivt@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.