Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > why bug in the program

Reply
Thread Tools

why bug in the program

 
 
prava sahoo
Guest
Posts: n/a
 
      02-01-2012
class foo
{
static int xxx;
static int zzz;
};
static int xxx =2;
int foo:xx = 1; // error here
int foo::zzz = 1;
static int zzz =2;

When compiled (gcc 2.4.5) It give an error for redefining xxx, but
not
for zzz,

because xxx is a static variable and its scope is inside the total
program so we can create only a single copy of this variable but zzz
in general variable inside class foo zzz is local to that class
foo .outside the class zzz is a variable of the program program .
these are consider two different variable with same name.
 
Reply With Quote
 
 
 
 
Miles Bader
Guest
Posts: n/a
 
      02-01-2012
prava sahoo <(E-Mail Removed)> writes:
> When compiled (gcc 2.4.5) It give an error for redefining xxx, but not
> for zzz,


Do you really have gcc version 2.4.5?! It was released about 20 years
ago!!! :OOO

[Recent versions of gcc (4.4-4.7) don't give any error for your
example.]

-miles

--
Clarionet, n. An instrument of torture operated by a person with cotton in his
ears. There are two instruments that are worse than a clarionet -- two
clarionets.
 
Reply With Quote
 
 
 
 
gwowen
Guest
Posts: n/a
 
      02-01-2012
On Feb 1, 7:11*am, Gareth Owen <(E-Mail Removed)> wrote:

> foo:xx = 1; // the compiler already knows it's an int.


Sorry, brain malfunction. Please please please ignore that.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 5.38 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? PerlFAQ Server Perl Misc 0 03-09-2011 11:00 PM
FAQ 5.38 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? PerlFAQ Server Perl Misc 0 02-11-2011 05:00 AM
*bug* *bug* *bug* David Raleigh Arnold Firefox 12 04-02-2007 03:13 AM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM



Advertisments