How to deal with constructor argument names?
- by Bane
Say I have a class that has some properties, like x, y, width and height. In its constructor, I couldn't do this:
class A
{
public:
A(int, int, int, int);
int x;
int y;
int width;
int height;
};
//Wrong and makes little sense name-wise:
A::A(int x, int y, int width, int height)
{
x = x;
y = y;
width = width;
height = height;
}
First of all, this doesn't really make sense. Second, x, y, width and height become some weird values (-1405737648) when compiled using g++. It does work, however, if I append "a" to the argument names.
What is the optimal way of solving these naming conflicts?