BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

static const AnsiString

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
sam
Guest





PostPosted: Wed Aug 10, 2005 9:50 am    Post subject: static const AnsiString Reply with 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
(...)
};
Thanks.

Sam


Back to top
Chris Uzdavinis (TeamB)
Guest





PostPosted: Wed Aug 10, 2005 1:45 pm    Post subject: Re: static const AnsiString Reply with quote



"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);

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.