Hi all,
quick question: I am fiddling around with classes and am trying to define a private data member: const float PIE but the compiler i am using (Microsoft Visual C++ 2005 version 8 says:
1>c:\users\greg\documents\visual studio 2005\projects\area calculations\area calculations\geometry definition.cpp(7) : error C2758: 'geometry:
IE' : must be initialized in constructor base/member initializer list
When i try and do this( I typed the following:
geometry::geometry()
{
const geometry:
IE = 3.14159;
}
in the constructor says:
c:\users\greg\documents\visual studio 2005\projects\area calculations\area calculations\geometry.h(17) : see declaration of 'geometry:
IE'
1>c:\users\greg\documents\visual studio 2005\projects\area calculations\area calculations\geometry definition.cpp(8) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\greg\documents\visual studio 2005\projects\area calculations\area calculations\geometry definition.cpp(8) : error C2761: 'const float geometry:
IE' : member function redeclaration not allowed
1>c:\users\greg\documents\visual studio 2005\projects\area calculations\area calculations\geometry definition.cpp(8) : fatal error C1903: unable to recover from previous error(s); stopping compilation
1>Build log was saved at "file://c:\Users\Greg\Documents\Visual Studio 2005\Projects\area calculations\area calculations\Debug\BuildLog.htm"
1>area calculations - 4 error(s), 0 warning(s)
Can anyone explain to me what I should do to define a private data member as a const?
Thanks!
P.S. i realised that i didnt stick in "float" iin the definition but i did that after writing this and the same result occurrs...
quick question: I am fiddling around with classes and am trying to define a private data member: const float PIE but the compiler i am using (Microsoft Visual C++ 2005 version 8 says:
1>c:\users\greg\documents\visual studio 2005\projects\area calculations\area calculations\geometry definition.cpp(7) : error C2758: 'geometry:
When i try and do this( I typed the following:
geometry::geometry()
{
const geometry:
}
in the constructor says:
c:\users\greg\documents\visual studio 2005\projects\area calculations\area calculations\geometry.h(17) : see declaration of 'geometry:
1>c:\users\greg\documents\visual studio 2005\projects\area calculations\area calculations\geometry definition.cpp(8) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\greg\documents\visual studio 2005\projects\area calculations\area calculations\geometry definition.cpp(8) : error C2761: 'const float geometry:
1>c:\users\greg\documents\visual studio 2005\projects\area calculations\area calculations\geometry definition.cpp(8) : fatal error C1903: unable to recover from previous error(s); stopping compilation
1>Build log was saved at "file://c:\Users\Greg\Documents\Visual Studio 2005\Projects\area calculations\area calculations\Debug\BuildLog.htm"
1>area calculations - 4 error(s), 0 warning(s)
Can anyone explain to me what I should do to define a private data member as a const?
Thanks!
P.S. i realised that i didnt stick in "float" iin the definition but i did that after writing this and the same result occurrs...