[cross-posting removed]
On Wed, 27 Jul 2005 14:02:19 GMT, "Chris \( Val \)"
<ch******@bigpo nd.com.au> wrote:
"Francis Glassborow" <fr*****@robint on.demon.co.uk> wrote in message
news:So******* *******@robinto n.demon.co.uk.. .
[snip]
(in particular, const in C++ creates a
| compile time constant but this is not the case in C)
True, but even that can have it's quirks:
class Array
{
private:
const int NrElems;
int MyArray[ NrElems ];
public:
Array( int n ) : NrElems( n ) {}
};
[C++ Error] ConstTest.cpp(8 ): E2313 Constant expression required
Cheers,
Chris Val
This seems to be the Borland error message ... MSVC++ Toolkit
complains about an undeclared identifier:
error C2327: 'Array::NrElems ' : is not a type name, static, or
enumerator.
error C2065: 'NrElems' : undeclared identifier.
Thinking about this a little makes it clear why there is an error:
each instance of "Array" would potentially have a different size,
making it impossible to declare arrays of Array objects...somet hing
which is trivial to do with std::vector<>. Yet C++ objects, once they
are defined, should all have the same memory requirements, and these
must be known to the compiler.
--
Bob Hairgrove
No**********@Ho me.com