[LC++]static const char*
Roberto Diaz
roberto at vivaldi.dhis.org
Fri Dec 14 04:20:07 UTC 2001
Hi!
Well I have the following problem:
If I define something like this:
class foo
{
static const int a = 1;
// more things
};
I have no problems the compiler wont complaints..
But if I do this:
class foo
{
static const char *a = "this";
// more things
};
g++ complaints:
bwwidget.h:18: ANSI C++ forbids initialization of member `antiquewhite'
bwwidget.h:18: making `a' static
So I change the syntax (just playing a little bit) and instead of "static
const" I put "const static" so then:
bwwidget.h:17: ANSI C++ forbids in-class initialization of non-const static
member `this'
And since I want to make sure I add "public:"
class foo
{
public:
static const char *a = "this";
//more things
}
And now:
bwwidget.h:18: ANSI C++ forbids in-class initialization of non-const static
member `a'
I just want to have a constant with a value so I can call it "foo::a" but
I dont want to use namespaces (I supposed a class was a namespace somehow too)
Is there not a way to have an static const char* ????
Thank you!
--
Saludos
Roberto Díaz <roberto at vivaldi.dhis.org>
PLEASE HELP SAVE faqs.org!
http://www.faqs.org/save_faqs-org.html
More information about the tuxCPProgramming
mailing list