The const tag has no wiki summary.
0
votes
0answers
29 views
corrupted const reference to a temporary object (life time) [migrated]
While asking this question, I learned const reference to a temporary object is valid in C++:
int main ()
{
int a = 21;
int b = 21;
//int & sum = a + b; //error: invalid initialization ...
0
votes
1answer
70 views
Implementation defined behaviour changing const type in c
The C standard states that if an attempt is made to change a const type,the result is implementation defined.This gives error on my system,but what does it depend on(compiler,os)?
What are the ...
2
votes
2answers
207 views
In C# what is lifetime or lifespan of constant variable?
In C# if i declare a constant variable is any memory allocated to it as it acts as a compile time replacement? How long is the variable's life?
2
votes
4answers
257 views
Immutable Method in Java
In Java, there is the final keyword in lieu of the const keyword in C and C++.
In the latter languages there are mutable and immutable methods such as stated in the answer by Johannes Schaub - litb ...
2
votes
1answer
57 views
Reading data from file and const
Is it sane to let a read method on a file object to be const? For example
size_t read(void* buffer,size_t length) const;
The read method does not change the contents of the file, but updates the ...
9
votes
5answers
761 views
Zero as a constant?
I have come across this programming idiom recently:
const float Zero = 0.0;
which is then used in comparisons:
if (x > Zero) {..}
Can anyone explain if this is really any more efficient or ...
5
votes
2answers
1k views
Do people use const a lot when programming in Objective C?
Related: “sending 'const NSString *' to parameter of type 'NSString *' discards qualifiers” warning
Sometimes, I think it's useful though. I may need to pass an a table and want to make sure that the ...
3
votes
5answers
1k views
Difference between immutable and const
I've often seen the terms immutable and const used interchangeably. However, from my (little) experience, the two differ a lot in the 'contract' they make in code:
Immutable makes the contract that ...