Chris Uzdavinis (TeamB) Guest
|
Posted: Wed Aug 10, 2005 1:45 pm Post subject: Re: static const AnsiString |
|
|
"sam" <skneife3 (AT) wanadoo (DOT) fr> writes:
| Quote: | Ca, someone tell me why this line is not allowed in a class
class TPanier : public TForm
public:
static const AnsiString="bla bla bla";//ERROR HERE
(...)
};
|
You have a few problems. First, you're not declaring a variable.
There is no name provided for your string.
Second, you are not allowed to initialize any variables in the class
declaration unless they have a static const INTEGRAL type.
Instead, you'd need to do this:
class TPanier : public TForm
public:
// declaration
static const AnsiString qqch;
};
// .cpp file
// definition
AnsiString TPanier::qqch("bla bla bla");
Static variables must be defined only once, so the definition goes in
a single .cpp file. (This is similar in concept to declaring a global
variable, except it is contained inside a class.)
--
Chris (TeamB);
|
|