What is the meaning of leading underscores in a C++ constructor?

Nothing special. He just named it like that to distinguish between the member variables and parameter names.

Underscore is a valid character in C++ identifiers.


It's just a convenient naming convention, it means nothing to the language. Just be sure you don't follow it with an upper-case letter: What does double underscore ( __const) mean in C?


Most likely, the author of the code was trying to avoid the potential conflict between the data member names and constructor parameter names in the initializer list. Quite likely, the author was not aware of the fact that C++ lookup rules make sure that the conflict will not occur anyway. I.e. the following code will also produce expected results

class floatCoords    {
    public:
        floatCoords(float x, float y, float width, float height)
                : x(x), y(y), width(width), height(height)
        {
        }
        float x, y, width, height;
        ...

although it might prove to be confusing for an unprepared reader.

Of course, inside the body of the constructor, parameter names will hide the member names, thus making it necessary to use this->... or qualified names to access the data members. Chances are the author of the code was trying to avoid that as well.