4 ms·
Can you please provide some examples, so I can better understand what you mean?
by golergka 11y ago
Can you please provide some examples, so I can better understand what you mean?
- trashcan 11y agoIf you make a function that accepts an unsigned int, and then you try to pass in a const unsigned int, you will need to either typecast it, make a new function, or change the function to only accept const unsigned ints. Although it's been a long time since I coded in C/C++, correct me if I'm wrong.
- Joky 11y agoThat sounds completely wrong, unless the function takes a reference to the unsigned int.
- StephanTLavavej 11y agoYou're incorrect, for C89 through C++17. I'd recommend not making statements about languages you've forgotten. In the C++ Working Paper, the Standardese is N4527 5.2.2 [expr.call]/4 "When a function is called, each parameter (8.3.5) shall be initialized (8.5, 12.8, 12.1) with its corresponding argument." followed by 8.5 [dcl.init] where /17.8 has a nice example: "Note: An expression of type "cv1 T" can initialize an object of type "cv2 T" independently of the cv-qualifiers cv1 and cv2. int a; const int b = a; int c = b;" (A "cv-qualifier" is const or volatile; they behave similarly in many contexts, hence the collective terminology for convenience.)
- trashcan 11y agoI stand corrected, thank you.
- agumonkey 11y agoI'm no C nor Ada expert, but I think he means in C `const` is a data type modifier, whereas in Ada it's a function modifier, making the concerns orthogonal. I'm never happy when I see warning about `const` being lifted by some function in C. I think that's what parent is referring to.