delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/15/13:45:23

From: md3den AT mdstud DOT chalmers DOT se (Dennis Bjorklund)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Difference between struct setups
Date: 15 Oct 1997 09:15:37 GMT
Organization: Chalmers University of Technology
Message-ID: <6221jp$shm$1@nyheter.chalmers.se>
References: <199710130605 DOT TAA20415 AT fep1-orange DOT clear DOT net DOT nz>
NNTP-Posting-Host: rizzo9.mdstud.chalmers.se
Mime-Version: 1.0
Lines: 37
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <199710130605 DOT TAA20415 AT fep1-orange DOT clear DOT net DOT nz>,
	"Jamie Love" <jamie DOT love AT clear DOT net DOT nz> writes:

JL>typedef struct X
JL> {
JL>    .....
JL> } X;
JL>..
JL>X x;

This is the way you often use in C. (but it works in C++ too)

JL>Now, when i was programming in borlands compiler, i just went:
JL>
JL>struct X
JL> {
JL>   .....
JL> };
JL>..
JL>X x;

And this only works in C++. If this had been C then you would have to write
"struct X x" istead of "X x". So it works in djgpp if you compile it as
a C++ program.

The C example above typdefs the name X to be the structure. So you can
write just X x. In C++ this is done automaticly. 

JL>struct X
JL> {
JL>   .....
JL> }y;

This is valid in both C and C++.

-- 
/Dennis

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019