From: czgrr <czgrr@my-deja.com>
Subject: Re: differences between C and Ada
Date: 1999/07/22
Date: 1999-07-22T00:00:00+00:00 [thread overview]
Message-ID: <7n718n$pet$1@nnrp1.deja.com> (raw)
In-Reply-To: 7n6ioe$lkd$1@nnrp1.deja.com
In article <7n6ioe$lkd$1@nnrp1.deja.com>,
aurelien_ratti@my-deja.com wrote:
> Hello.
Hello.
> What is the difference between C's static variables and Ada's global
> variables ?
One difference is that Ada's global variables have to be, er, global.
That means anything in the package that declares them can access them.
In C++ (and, I assume, C), a static variable can be declared at local
scope, but still has the lifetime of a global.
Another difference is that the C++ compiler will automatically
initialise a static variable to 0 before it is first used. In Ada, you
still have to explicitly initialise it.
A third difference (possibly, I haven't tried it) is that if you have a
C++ class with a static variable, there is only one instance of the
variable regardless of how many objects there are of that class, even
if there are none. In Ada (I think), a global variable in a generic
package exists once per instantiation. Don't know if or how this
translates to C.
I'm sure there's more.
Cheers,
czgrr
--
Email address blocked - reply to the newsgroup.
Assume Ada83 and (V)C++ unless said otherwise.
My opinions are independent from my employer's.
Use any suggestions at your own risk.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
next prev parent reply other threads:[~1999-07-22 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-07-22 0:00 differences between C and Ada aurelien_ratti
1999-07-22 0:00 ` czgrr [this message]
1999-07-22 0:00 ` Steve Folly
1999-07-26 0:00 ` aurelien_ratti
1999-07-22 0:00 ` Martin Gangkofer
1999-07-22 0:00 ` Ted Dennison
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox