Topic: typedef's and const's


Author: hennebry@plains.NoDak.edu (Michael J. Hennebry)
Date: 1998/03/19
Raw View
Consider the following code fragment:

typedef char *String;
const char *str1;
const String str2;

Are str1 and str2 supposed to be the same type?

I've been trying to code some X stuff in C++ .
Some pointers to functions have been giving me fits because their argument
lists differ in just that way.  The compiler says they're different.

--
Mike   hennebry@plains.NoDak.edu
"The wolf [Shelob Johnson] and I are now on a first name basis."  --  Ivanova
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Anatoli <REMOVETHISanatoli@ptc.com>
Date: 1998/03/19
Raw View
Michael J. Hennebry wrote:
>
> Consider the following code fragment:
>
> typedef char *String;
> const char *str1;
> const String str2;
>
> Are str1 and str2 supposed to be the same type?
>

Nope :  const char * is const char *,
while const String is char * const.

Regards
--
Anatoli (anatoli at ptc dot com)
opinions aren't


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: jkanze@otelo.ibmmail.com
Date: 1998/03/19
Raw View
In article <6eph4d$hs7@plains.NoDak.edu>,
  hennebry@plains.NoDak.edu (Michael J. Hennebry) wrote:
>
> Consider the following code fragment:
>
> typedef char *String;
> const char *str1;
> const String str2;
>
> Are str1 and str2 supposed to be the same type?

No. "const String" =3D=3D "String const" =3D=3D "char *const".

--
James Kanze    +33 (0)1 39 23 84 71    mailto: kanze@gabi-soft.fr
        +49 (0)69 66 45 33 10    mailto: jkanze@otelo.ibmmail.com
GABI Software, 22 rue Jacques-Lemercier, 78000 Versailles, France
Conseils en informatique orient=E9e objet --
              -- Beratung in objektorientierter Datenverarbeitung

-----=3D=3D Posted via Deja News, The Leader in Internet Discussion =3D=3D=
-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: agriffiths@ma.ccngroup.com (Alan Griffiths)
Date: 1998/03/19
Raw View
In article: <6eph4d$hs7@plains.NoDak.edu>  hennebry@plains.NoDak.edu (Michael J. Hennebry) writes:
>
> Consider the following code fragment:
>
> typedef char *String;
> const char *str1;
> const String str2;
>
> Are str1 and str2 supposed to be the same type?

No. "str1" is of type "const char*", "str2" is of type "char* const".

__
Alan Griffiths              | Senior Systems Consultant, Experian (Formerly CCN)
alan.griffiths@experian.com (agriffiths@ma.ccngroup.com, Tel. +44 115 934 4517)
(ACCU C++ SIG organiser     | <http://www.accu.org/> alan@octopull.demon.co.uk)




[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: hennebry@plains.NoDak.edu (Michael J. Hennebry)
Date: 1998/03/19
Raw View
In article <Eq2Lv3.ro@research.att.com>,
Andrew Koenig <ark@research.att.com> wrote:
>In article <6eph4d$hs7@plains.NoDak.edu>,
>Michael J. Hennebry <hennebry@plains.NoDak.edu> wrote:
>
>> typedef char *String;
>> const char *str1;
>> const String str2;
>
>> Are str1 and str2 supposed to be the same type?
>
>No: str1 is a pointer to a constant character,
>and str2 is a constant pointer to character.

Thanks, it's what I suspected.
SGI has tried to improve tahe Xlib headers.
It's giving me pain.  I settled for coercion.

--
Mike   hennebry@plains.NoDak.edu
"The wolf [Shelob Johnson] and I are now on a first name basis."  --  Ivanova


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]