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

Jorge picture Jorge · Oct 19, 2009 · Viewed 13.1k times · Source

OK I am not a very experienced C++ programmer, but I was wondering what is the significance of the underscores in the arguments of the following constructor?

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;
  ...

Answer

mmx picture mmx · Oct 19, 2009

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.