473,385 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 1399

"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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.