I often see code examples where the constructor arguments have the same name as the class members. How does the compiler distinguish the function argument names from the class member names? Is this portable code? Is this bad practice?
Example:
class Box
{
public:
Box(unsigned length, unsigned width, unsigned height)
: length(length), width(width), height(height)
{
std::clog << length << std::endl;
std::clog << width << std::endl;
std::clog << height << std::endl;
}
private:
unsigned length, width, height;
};