On Dec 12, 6:50*am, James Kuyper <jameskuy...@verizon.net> wrote:
> srikar2097 wrote:
> > I get it now, so lptr becomes a pointer of type long. Is that it?
> > But why would anyone want to do it this way? Does it have any
> > advantage?
>
> > To change it a bit -
>
> > long foo = 42;
> > long *lptr = &foo;
>
> > doesn't this suffice?
>
> Sure, but the people who use this approach consider it convenient to be
> able to write LGP rather than long*. However, if you consider the need
> to use the shift key, most of the convenience argument disappears. A
> more important problem is that this typedef hides the pointer nature of
> the variable, which is considered by many people to be dangerous. I
> wouldn't use this typedef.
maybe the program needs different types under different circumstances
or on different platforms. Using a typedef then makes it simple to
change between types, changing only one line instead of everywhere
that type is used.
#ifdef CIRCUMSTANCE_ONE
typedef long LG, *LGP;
#else
typedef long long LG, *LGP;
#endif
--
Fred K
|