How do I define a constant expression with in a class?

Started by
39 comments, last by spiffgq 21 years, 4 months ago
risingdragon3 - don''t you get it yet ... you return the address of ANY of them ... usually the compiler will pick the first one, because it knows about it first, and stores its address in the symbol table when it computes it

the whole key is that we are talking about const objects, so the ONLY valid thing to do to an address of a const object is to compare it to another address, and read it''s value ... so any address will do ... this is NOT a theoretical only discussion, compilers actually DO this.

ChaosEngine - as i said, there IS support in C++ for const definitions in the class header in C++, IF AND ONLY IF they are of integer type ...

AND FOR VISUAL C++ 6.0 DO NOT DECLARE THEM STATIC, and you get no trouble ... because it is an integral constant, it makes no difference if it is static or not ... the compiler will NOT increade the size of your objects to hold const ints ... try it and see ...

This topic is closed to new replies.

Advertisement