"const" not used in VC .NET

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
Can any body tell me that instead of "const" what can we use in MC++.
Thanks in advance!!
 
Surmeet Jandu said:
Hi,
Can any body tell me that instead of "const" what can we use in MC++.
Thanks in advance!!

There is no alternative for managed code. .NET doesn't support
const-correctness.

If you want a symbolic constant, then C++/CLI has "literal". I don't know
what the Managed Extensions for C++ syntax is for that, but you should
upgrade to VC2005 anyway.
 
Can any body tell me that instead of "const" what can we use in MC++.
Thanks in advance!!

Common sense?! LOL

Seriously, 'const' theoretically can prevent some programming slip ups, but
there are things (such as some templated lists) that defy 'const' even when
used in operations that don't seem to change anything, since merely
referencing them causes them to change (not sure why, but I've seen this
happen). Thus, I've had a program jam packed with 'const' constraints in the
past, only to introduce a list array, forcing me to remove the 'const' from
anything that ever referenced the list, or referenced anything that
referenced the list, or referenced anything that referenced anything that
referenced the list, etc.

As such, I gave up on 'const' a long time ago, as it introduced more
headaches than removing problems, and now I just use... you guessed
it...common sense...! :)

[==Peter==]
 
Back
Top