473,804 Members | 3,088 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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 1417

"Surmeet Jandu" <Su**********@d iscussions.micr osoft.comwrote in message
news:FE******** *************** ***********@mic rosoft.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**********@d iscussions.micr osoft.comwrote in message
news:FE******** *************** ***********@mic rosoft.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
2624
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
3261
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? Then, I found, in this book, the semantic of set::iterator is defined as same as set::const_iterator. Both of them must be const! I tried to read the source of GNU STL(version 3.4.1).They were using a red-black tree to implant it (std::set has a...
3
2482
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 wrong? I am using g++ (GCC) 3.3.5 on a Debian Sarge system. The compiler complains: //**************************** //**************************** Compiler output starts *********** cd /home/red/tmp/testprogs/
2
6493
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 printf("%sHello World%s\n", green, normal); 12 return 0; 13 }
4
6094
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 definition errors if the header file is #include'd in more than one code file. The answer was that constants have internal linkage unless declared extern, so it's OK. So, you can put something like...
16
2122
by: recover | last post by:
#include <string> #include <iostream> using namespace std; class TConst { private: string con; string uncon; public:
7
14706
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 the const pointer (i.e. t)? I got a segmentation fault in the last for loop. Thanks in advance! #include <iostream> using namespace std;
3
2122
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 it can be compiled? We have used it for years.
7
1934
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 article/tutorial that can help me? Thanks a lot!
0
9705
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9575
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10308
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9134
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7609
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6846
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3806
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2981
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.