problem with "static const"

Started by
12 comments, last by n0rmanfreak 18 years, 1 month ago
Quote:Original post by Bregma
Did you define your consts, or did you just declare them.
class StatID{public:    static const int A = 1;    static const int B = 2;};

That's defining them, not declaring them.

Quoted for being almost the right answer. That is how you should write it, but it's still just declarations, not definitions. Although most compilers seem to let you elide it, according to the final draft standard you still need the definitions too:
// statid.hclass StatID{	public:		static const int A = 1;		static const int B = 2;		// ...};// statid.cppconst int StatID::A;const int StatID::B;// ...
Σnigma
Advertisement
hi enigma!

as stated in my above post...this doesn't compile :(
it gives me errors C2258 and C2252. i'm using vc++ 6.0 with sp2

Hey bud

It doesn't surprise that VS6 is giving you problems with this. It might be worth making the transition over toVS2005 now.

Dave
hi Dave!

and thx for your quick answer...i just figured out something like that while asking google for some help ;)

thx all


edit: many typos :(

[Edited by - n0rmanfreak on March 14, 2006 10:59:08 AM]

This topic is closed to new replies.

Advertisement