Mail Archives: djgpp/1998/09/08/16:31:51
From: | Erik Max Francis <max AT alcyone DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: how do i define structures ?
|
Date: | Tue, 08 Sep 1998 13:10:42 -0700
|
Organization: | Alcyone Systems
|
Lines: | 36
|
Message-ID: | <35F58F42.6D71B0B5@alcyone.com>
|
References: | <000101bdd8ea$aa4d9540$5d4d08c3 AT arthur>
|
NNTP-Posting-Host: | charmaine.alcyone.com
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Arthur wrote:
> Do you actually need the last mystruct? Perhaps I've been using C++
> for too
> long (where you don't even need typedef), ...
Well, typedef certainly still exists, but isn't necessary when defining
structs, classes, and unions.
> ... but I thought that you could
> define a typedef'd structure thus:
>
> typedef structs mystruct {
> int x;
> int y;
> }
This is illegal. You meant
typedef struct {
int x, y;
} mystruct;
This declares an anonymous struct (one with no tag), and typedefs it to
be mystruct. The usual way that typedefs are used with structurs
declares both a tag (e.g., struct X) and the type by itself (e.g., X).
The typedefs are unnecessary in C++, but also do not do any harm.
--
Erik Max Francis / email max AT alcyone DOT com / whois mf303 / icq 16063900
Alcyone Systems / irc maxxon (efnet) / finger max AT sade DOT alcyone DOT com
San Jose, CA / languages En, Eo / web http://www.alcyone.com/max/
USA / icbm 37 20 07 N 121 53 38 W / &tSftDotIotE
\
/ Many things are lost for want of asking.
/ (an English proverb)
- Raw text -