472,782 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,782 software developers and data experts.

"const" not used in VC .NET

Hi,
Can any body tell me that instead of "const" what can we use in MC++.
Thanks in advance!!
Oct 12 '07 #1
3 1365

"Surmeet Jandu" <Su**********@discussions.microsoft.comwrote in message
news:FE**********************************@microsof t.com...
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.

Oct 12 '07 #2
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==]
"Surmeet Jandu" <Su**********@discussions.microsoft.comwrote in message
news:FE**********************************@microsof t.com...
Hi,
Can any body tell me that instead of "const" what can we use in MC++.
Thanks in advance!!

Oct 15 '07 #3
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...! :)
http://www.gotw.ca/gotw/006.htm
Oct 16 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: zealotcat | last post by:
template <class T> inline T const& max (T const& a, T const& b) { // if a < b then use b else use a return a<b?b:a; } thanks very much!!
11
by: snnn | last post by:
On the book <Generic Programming and the STL>( Matthew . H . Austern ),this function is defined as iterator set::begin() const. However, why should a const object returns a non-const iterator?...
3
by: H. S. | last post by:
Hi, I am trying to compile these set of C++ files and trying out class inheritence and function pointers. Can anybody shed some light why my compiler is not compiling them and where I am going...
2
by: s88 | last post by:
Hi all: I saw the code likes... 7 #include <stdio.h> 8 int main(void){ 9 const char *const green = "\033[0;40;32m"; 10 const char *const normal = "\033[0m"; 11 ...
4
by: C. J. Clegg | last post by:
A month or so ago I read a discussion about putting const ints in header files, and how one shouldn't put things in header files that allocate memory, etc. because they will generate multiple...
16
by: recover | last post by:
#include <string> #include <iostream> using namespace std; class TConst { private: string con; string uncon; public:
7
by: xgngli | last post by:
Hi all! I've taken some time on learning the difference between "pointers to const variables" and "const pointer variables". The question is: in the following code, can we change the contents of...
3
by: coala | last post by:
In Smart Pointer class, we have a piece of code: inline void release(void) const { if (mPtr) mPtr->release(); mPtr = 0; } It can set mPtr but it is still const? Why could this work and why...
7
by: Luna Moon | last post by:
Hi all, I just couldn't get myself clear about the usage of "const" in front of and/or behind variables, pointers, classes, objects and functions... It's too confusing... any good clear...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.