When passed by reference, a match check is performed:
class CTest { private: int memberA; double memberB; public: void initialize(const int &a, const double b); }; void CTest::initialize(int &a,double b) // 'initialize' - member function already defined with different parameters { memberA = a; memberB = b; }
Because in this case it would (could) change the caller state. While with by value, const or not const is without any impact outside the function.
You have the choice to be consistent or not.

Why does a function declaration with a const argument allow calling of a function with a non-const argument?
- 2010.09.09
- Alerty Alerty 5,935 7 7 gold badges 38 38 silver badges 62 62 bronze badges
- stackoverflow.com
Take note of the following C++ code: Notice that the prototype of takes a and that the definition takes an . This compile without any errors... Why are there no compilation errors?

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The following code compiles without errors or warnings:
How normal is this? Personally, I would like to see a compilation error in such a case.