4 ms·
We can declare a const pointer to a const object - irritating ceremony but still possible.
by hardlianotion 5y ago
We can declare a const pointer to a const object - irritating ceremony but still possible.
- injidup 5y agoNot irritating at all. You are saying that you can't swap the pointed at object for another one AND that you can't change the pointed at object. Two very different things. You have four possible combinations all with different meanings. It's also why I always I insist on putting const to the right of the declaration part the const is referring too. The C++ standard allows const to the left IF it is the first const. But I think this flexibility is kind of garbage....
- hardlianotion 5y agoTrue, but I am a little sensitive to a multiplicity of keywords on a line. Agree about the variable placing being not great. The trouble is most folk use the flexibility to bind the const in the wrong direction, myself included. Then putting it "right" looks "wrong".