Author: Bo Persson
Date: 13:40:06 02/27/03
Go up one level in this thread
On February 27, 2003 at 09:55:35, Tom Likens wrote: >On February 26, 2003 at 17:07:45, Bo Persson wrote: > >[--snip--] > > >>>I see that I did not include data.h in data.c but it caused me no problem >>>with c files >> >>You have found an actual difference between the languages! >> >>In C++, const variables are considered local unless declared otherwise. In C, >>all global (file level) variables are extern by default. >> >>Bo Persson >>bop2@telia.com > > >No, no- C++ is just a superset of C. There is *absolutely* >no differences between them :-) :-) :-) :-) :-) ;-) This is actually kind of fun: The idea of 'const' first appeared in C++, where the use for globals is much less than in C. So it was considered a good idea to have constants local to each file by default. Even if you accidentally got several copies, one in each file, they would have the same value anyway (kind of the idea behind a constant :-) and the optimizer would probably get rid of most of them. As C didn't even have 'const' at the time, this couldn't be a compatibility problem. Only later did the C guys learn about these constants and included the idea in their language, just slightly different... A "forward compatibility" problem? >regards, >--tom Bo Persson bop2@telia.com
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.