Hello,

I got a class that i defined

class ProbabilityEngine
{

public:

static int index_x;

static int index_y;

static LaplaceStatistics *Laplace_array;

static GaussStatistics *Gauss_array;

void CreateFeat();

void CreateXis();

};

I then define the functions in the .cpp and initialise the static
menbers variables and functions.

But when I try to do the following :

ProbabilityEngine my_engine;
my_engine.CreateFeat();

I get the error : D:\Bayesian Programming\Form\FormDlg.cpp(50) : error
C2143: syntax error : missing ';' before '.'
D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2501:
'Prob_engine' : missing storage-class or type specifiers
D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2371:
'Prob_engine' : redefinition; different basic types
D:\Bayesian Programming\Form\FormDlg.cpp(40) : see declaration
of 'Prob_engine'

and really i'm lost...could there be a problem with static members or
something else?

Re: Class problem by John

John
Tue Apr 19 10:40:03 CDT 2005

"François" <francois.aspert@epfl.ch> wrote in message
news:4265238b$1@epflnews.epfl.ch
> Hello,
>
> I got a class that i defined
>
> class ProbabilityEngine
> {
>
> public:
>
> static int index_x;
>
> static int index_y;
>
> static LaplaceStatistics *Laplace_array;
>
> static GaussStatistics *Gauss_array;
>
> void CreateFeat();
>
> void CreateXis();
>
> };
>
> I then define the functions in the .cpp and initialise the static
> menbers variables and functions.
>
> But when I try to do the following :
>
> ProbabilityEngine my_engine;
> my_engine.CreateFeat();
>
> I get the error : D:\Bayesian Programming\Form\FormDlg.cpp(50) : error
> C2143: syntax error : missing ';' before '.'
> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2501:
> 'Prob_engine' : missing storage-class or type specifiers
> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2371:
> 'Prob_engine' : redefinition; different basic types
> D:\Bayesian Programming\Form\FormDlg.cpp(40) : see declaration
> of 'Prob_engine'
>
> and really i'm lost...could there be a problem with static members or
> something else?

Prob_engine occurs repeatedly in those error messages, but there is nothing
in the code you have supplied that uses that identifier. I'd follow the
compiler's advice and see the declaration of Prob_engine.


--
John Carson


Re: Class problem by Victor

Victor
Tue Apr 19 10:41:08 CDT 2005

François wrote:
> I got a class that i defined
>
> class ProbabilityEngine
> {
>
> public:
>
> static int index_x;
>
> static int index_y;
>
> static LaplaceStatistics *Laplace_array;
>
> static GaussStatistics *Gauss_array;
>
> void CreateFeat();
>
> void CreateXis();
>
> };
>
> I then define the functions in the .cpp and initialise the static
> menbers variables and functions.
>
> But when I try to do the following :
>
> ProbabilityEngine my_engine;
> my_engine.CreateFeat();
>
> I get the error : D:\Bayesian Programming\Form\FormDlg.cpp(50) : error
> C2143: syntax error : missing ';' before '.'
> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2501:
> 'Prob_engine' : missing storage-class or type specifiers
> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2371:
> 'Prob_engine' : redefinition; different basic types
> D:\Bayesian Programming\Form\FormDlg.cpp(40) : see declaration
> of 'Prob_engine'

What line is FormDlg.cpp(50)? WTF is 'Prob_engine'? Your class is called
'ProbabilityEngine', did you forget to change it in 'FormDlg.cpp'?

> and really i'm lost...could there be a problem with static members or
> something else?

Post the code which actually gives you the error.

V

Re: Class problem by Scott

Scott
Tue Apr 19 11:38:36 CDT 2005

François wrote:

> Hello,
>
> I got a class that i defined
>
> class ProbabilityEngine
> {
>
> public:
>
> static int index_x;
>
> static int index_y;
>
> static LaplaceStatistics *Laplace_array;
>
> static GaussStatistics *Gauss_array;
>
> void CreateFeat();
>
> void CreateXis();
>
> };
>
> I then define the functions in the .cpp and initialise the static
> menbers variables and functions.
>
> But when I try to do the following :
>
> ProbabilityEngine my_engine;
> my_engine.CreateFeat();
>
> I get the error : D:\Bayesian Programming\Form\FormDlg.cpp(50) : error
> C2143: syntax error : missing ';' before '.'
> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2501:
> 'Prob_engine' : missing storage-class or type specifiers
> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2371:
> 'Prob_engine' : redefinition; different basic types
> D:\Bayesian Programming\Form\FormDlg.cpp(40) : see declaration
> of 'Prob_engine'
>
> and really i'm lost...could there be a problem with static members or
> something else?


From the information you have provided, it looks like you simply called
it 'ProbabilityEngine' one place and 'Prob_engine' another place.

--
Scott McPhillips [VC++ MVP]


Re: Class problem by francois

francois
Tue Apr 19 11:53:15 CDT 2005

Well, actually, the declaration :

ProbabilityEngine my_engine;

seem to compile properly but when I try the following

my_engine.CreateFeat();

I get the previous error message at this particular instruction

Victor Bazarov wrote:
> François wrote:
>
>> I got a class that i defined
>>
>> class ProbabilityEngine
>> {
>>
>> public:
>>
>> static int index_x;
>>
>> static int index_y;
>>
>> static LaplaceStatistics *Laplace_array;
>>
>> static GaussStatistics *Gauss_array;
>>
>> void CreateFeat();
>>
>> void CreateXis();
>>
>> };
>>
>> I then define the functions in the .cpp and initialise the static
>> menbers variables and functions.
>>
>> But when I try to do the following :
>>
>> ProbabilityEngine my_engine;
>>
>>
>> I get the error : D:\Bayesian Programming\Form\FormDlg.cpp(50) : error
>> C2143: syntax error : missing ';' before '.'
>> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2501:
>> 'Prob_engine' : missing storage-class or type specifiers
>> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2371:
>> 'Prob_engine' : redefinition; different basic types
>> D:\Bayesian Programming\Form\FormDlg.cpp(40) : see declaration
>> of 'Prob_engine'
>
>
> What line is FormDlg.cpp(50)? WTF is 'Prob_engine'? Your class is called
> 'ProbabilityEngine', did you forget to change it in 'FormDlg.cpp'?
>
>> and really i'm lost...could there be a problem with static members or
>> something else?
>
>
> Post the code which actually gives you the error.
>
> V

Re: Class problem by francois

francois
Tue Apr 19 11:55:04 CDT 2005

Um sorry, the code is :

ProbabilityEngine Prob_engine;

seem to compile properly but when I try the following

Prob_engine.CreateFeat();

I get the following error message at this particular instruction

D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2143: syntax error
: missing ';' before '.'
D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2501:
'Prob_engine' : missing storage-class or type specifiers
D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2371:
'Prob_engine' : redefinition; different basic types
D:\Bayesian Programming\Form\FormDlg.cpp(40) : see declaration
of 'Prob_engine'

Re: Class problem by Victor

Victor
Tue Apr 19 10:57:30 CDT 2005

François wrote:
> Well, actually, the declaration :
>
> ProbabilityEngine my_engine;
>
> seem to compile properly but when I try the following
>
> my_engine.CreateFeat();
>
> I get the previous error message at this particular instruction

(a) Please don't top-post. Thanks.

(b) Read the C++ FAQ Lite (http://www.parashift.com/c++-faq-lite/).
5.8 actually addresses your exact problem. I am sure it applies
here.

> [...]

V

Re: Class problem by Tom

Tom
Tue Apr 19 11:03:49 CDT 2005

François wrote:
> Um sorry, the code is :
>
> ProbabilityEngine Prob_engine;
>
> seem to compile properly but when I try the following
>
> Prob_engine.CreateFeat();
>
> I get the following error message at this particular instruction
>
> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2143: syntax error
> : missing ';' before '.'
> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2501:
> 'Prob_engine' : missing storage-class or type specifiers
> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2371:
> 'Prob_engine' : redefinition; different basic types
> D:\Bayesian Programming\Form\FormDlg.cpp(40) : see declaration
> of 'Prob_engine'

The code is in a function, right? Those errors sound like what you might
get if you tried to put "Prob_engine.CreateFeat();" at global scope!

Tom

Re: Class problem by Victor

Victor
Tue Apr 19 11:05:04 CDT 2005

François wrote:
> Um sorry, the code is :
>
> ProbabilityEngine Prob_engine;
>
> seem to compile properly but when I try the following
>
> Prob_engine.CreateFeat();
>
> I get the following error message at this particular instruction
>
> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2143: syntax error
> : missing ';' before '.'
> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2501:
> 'Prob_engine' : missing storage-class or type specifiers
> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2371:
> 'Prob_engine' : redefinition; different basic types
> D:\Bayesian Programming\Form\FormDlg.cpp(40) : see declaration
> of 'Prob_engine'

It seems that 'ProbabilityEngine' class definition is not visible when you
compile your 'FormDlg.cpp'. Did you include appropriate headers?

V

Re: Class problem by francois

francois
Tue Apr 19 12:29:22 CDT 2005

Tom Widmer wrote:
> François wrote:
>
>> Um sorry, the code is :
>>
>> ProbabilityEngine Prob_engine;
>>
>> seem to compile properly but when I try the following
>>
>> Prob_engine.CreateFeat();
>>
>> I get the following error message at this particular instruction
>>
>> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2143: syntax
>> error : missing ';' before '.'
>> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2501:
>> 'Prob_engine' : missing storage-class or type specifiers
>> D:\Bayesian Programming\Form\FormDlg.cpp(50) : error C2371:
>> 'Prob_engine' : redefinition; different basic types
>> D:\Bayesian Programming\Form\FormDlg.cpp(40) : see declaration
>> of 'Prob_engine'
>
>
> The code is in a function, right? Those errors sound like what you might
> get if you tried to put "Prob_engine.CreateFeat();" at global scope!
>
> Tom


Right, i tried to access it at global scope!!
Thanks a lot

François