Re: List<> of struct with property. Cannot change value of property. why?
- From: "Ben Voigt" <rbv@xxxxxxxxxxxxx>
- Date: Tue, 15 May 2007 17:07:56 -0500
After all, in C++ there's a LOT of code that doesn't modify data that
isn't marked "const". Relying on the "const" keyword to enable a warning
wouldn't have been a good idea in C++, because you'd get a lot of false
positives due to the large amount of code that is "const" without using
"const".
Actually, in a good programmer's hands, that's a notice to the compiler that
the function is not guaranteed to leave the data unchanged. I'd hate for
the compiler to analyze a stub function, make an automatic determination of
const-ness, and somehow affect how the code around it is error-checked.
(Note that optimizing the generated machine code is ok, optimizing away
errors and warnings is not).
Understanding and using const-correctness is a prerequisite for being a
professional C++ programmer. It's an important part of documentation,
compile-time error checking, and enables automatic optimizations that
couldn't otherwise be performed.
.
- Follow-Ups:
- References:
- List<> of struct with property. Cannot change value of property. why?
- From: Zytan
- Re: List<> of struct with property. Cannot change value of property. why?
- From: Bruce Wood
- Re: List<> of struct with property. Cannot change value of property. why?
- From: Zytan
- Re: List<> of struct with property. Cannot change value of property. why?
- From: Zytan
- Re: List<> of struct with property. Cannot change value of property. why?
- From: Jon Skeet [C# MVP]
- Re: List<> of struct with property. Cannot change value of property. why?
- From: Zytan
- Re: List<> of struct with property. Cannot change value of property. why?
- From: Jon Skeet [C# MVP]
- Re: List<> of struct with property. Cannot change value of property. why?
- From: Christof Nordiek
- Re: List<> of struct with property. Cannot change value of property. why?
- From: Peter Duniho
- Re: List<> of struct with property. Cannot change value of property. why?
- From: Zytan
- Re: List<> of struct with property. Cannot change value of property. why?
- From: Peter Duniho
- List<> of struct with property. Cannot change value of property. why?
- Prev by Date: Re: Exception handling
- Next by Date: Re: Regex to remove \t \r \n from string
- Previous by thread: Re: List<> of struct with property. Cannot change value of property. why?
- Next by thread: Re: List<> of struct with property. Cannot change value of property. why?
- Index(es):
Relevant Pages
|