An error occurs when declaring a constant:

warning C4459: the "speedRange" ad hides the global ad

The header file contains:

typedef std::pair<int, int> Speed; typedef std::map<Gear, Speed> SpeedRange; extern const SpeedRange speedRange; 

And in CPP

 const SpeedRange speedRange = { { Gear::REVERSE, Speed(0, 20) }, { Gear::NEUTRAL_GEAR, Speed(MIN_SPEED, MAX_SPEED) }, { Gear::FIRST_GEAR, Speed(0, 30) }, { Gear::SECOND_GEAR, Speed(20, 50) }, { Gear::THIRD_GEAR, Speed(30, 60) }, { Gear::FOURTH_GEAR, Speed(40, 90) }, { Gear::FIFTH_GEAR, Speed(50, 150) } }; 

    1 answer 1

    Write as

     extern const SpeedRange speedRange = { //... 

    By default, constants have an internal binding, and therefore, without the extern keyword, this declaration is considered an internal binding declaration and hides the external binding binding of the same name that is present in the title (which you may have forgotten to include. Check if the title is included in this module).

    From C ++ Standard (3.5 Program and linkage)

    - it is not subject to any linkage; or

    Or your definition of a constant is in some block of code, and not in the global namespace, as a result of which it hides the global declaration.