cui@maccs.dcss.mcmaster.ca (Jun Cui) (03/24/91)
Is anyone out there heard about AT&T ODE(Object Database and Environment),
which is based on AT&T C++?
In our system, we've got only AT&T Concurrent C++ (version 1.* something).
I'm wandering if this version could support AT&T ODE. I tried to declare
a constant integer in a class:
class test {
const int foo = 10;
// other ....
}
When compiling it using AT&T Concurrent C++, I was given a message
'error: initializer for member test::foo'.
AT&T Concurrent C++ uses a different way to initialize a constant?
Any help would be appreciated.
jun.mckulka@eldalonde.endor.cs.psu.edu (Christopher Mc Kulka) (03/24/91)
In article <27EC1A78.14249@maccs.dcss.mcmaster.ca> cui@maccs.dcss.mcmaster.ca (Jun Cui) writes: >I'm wandering if this version could support AT&T ODE. I tried to declare >a constant integer in a class: > > class test { > const int foo = 10; > // other .... > } > >When compiling it using AT&T Concurrent C++, I was given a message >'error: initializer for member test::foo'. >AT&T Concurrent C++ uses a different way to initialize a constant? What you need to do is have a constructor like the following test::test() : foo(10) { // do something} ; and remove the initializer from the class declaration. This is the same across all C++'s. >jun. Chris -- Just say *NO* to software patents & look-and-feel lawsuits. Try competition. If God had intended man to smoke he would have set him on fire. There are two ways to write an error-free program. Only the third works. Chris McKulka (mckulka@bree.endor.cs.psu.edu)
wmm@world.std.com (William M Miller) (03/25/91)
cui@maccs.dcss.mcmaster.ca (Jun Cui) writes: > class test { > const int foo = 10; > // other .... > } > > When compiling it using AT&T Concurrent C++, I was given a message > 'error: initializer for member test::foo'. > AT&T Concurrent C++ uses a different way to initialize a constant? Any C++ compiler should reject that; it's not legal C++. Even for int constants, the only way to initialize them is via the constructor's initialization list: class foo { const int i; foo(); //... }; foo::foo(): i(10) { } Of course, that means you can't use constant members for things like array bounds and the like, where a constant expression is required. For that, you can use an enumeration constant: class bar { enum { ARRAY_SIZE = 100 }; int array[ARRAY_SIZE]; //... }; -- William M. Miller, Glockenspiel, Ltd. wmm@world.std.com