www.digitalmars.com         C & C++   DMDScript  

c++.chat - How can I simulate java's final variable in C++?

reply "asman" <lol.themask gmail.com> writes:
How can I simulate java's final variable[1] in C++? But without 
an extra bool in the struct itself because it must have a 
fixed-size length which I use with #pragma pack(1) to prevent 
compiler to add padding. Is it possible?

[1]: http://en.wikipedia.org/wiki/Final_%28Java%29#Final_variables
Apr 16 2014
parent reply "asman" <lol.themask gmail.com> writes:
On Wednesday, 16 April 2014 at 20:38:40 UTC, asman wrote:
 How can I simulate java's final variable[1] in C++? But without 
 an extra bool in the struct itself because it must have a 
 fixed-size length which I use with #pragma pack(1) to prevent 
 compiler to add padding. Is it possible?

 [1]: 
 http://en.wikipedia.org/wiki/Final_%28Java%29#Final_variables
After see the date of last posts I hope someone still access this thread and see my message. :(
Apr 16 2014
parent "Max Barraclough" <. .> writes:
On Wednesday, 16 April 2014 at 20:42:54 UTC, asman wrote:
 On Wednesday, 16 April 2014 at 20:38:40 UTC, asman wrote:
 How can I simulate java's final variable[1] in C++? But 
 without an extra bool in the struct itself because it must 
 have a fixed-size length which I use with #pragma pack(1) to 
 prevent compiler to add padding. Is it possible?

 [1]: 
 http://en.wikipedia.org/wiki/Final_%28Java%29#Final_variables
After see the date of last posts I hope someone still access this thread and see my message. :(
Familiar with C++'s 'const' system? That's pretty much Java's final, only taken much further. I don't know what you're talking about with 'extra bool in the struct' though.
May 22 2014