From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: ** X-Spam-Status: No, score=2.3 required=5.0 tests=BAYES_00,HK_RANDOM_FROM, INVALID_MSGID,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d532947ad2f7bdcd X-Google-Attributes: gid103376,public From: czgrr Subject: Re: differences between C and Ada Date: 1999/07/22 Message-ID: <7n718n$pet$1@nnrp1.deja.com>#1/1 X-Deja-AN: 503967867 References: <7n6ioe$lkd$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x37.deja.com:80 (Squid/1.1.22) for client 193.192.234.4 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Thu Jul 22 12:02:35 1999 GMT X-MyDeja-Info: XMYDJUIDczgrr Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT) Date: 1999-07-22T00:00:00+00:00 List-Id: 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.