Constructor argument and member with the same name

Viewed 3580

I'm curious if the following code is valid. Static analysis is giving an error on this constructor.

Summary: Member variable 'A' is initialized by itself.

Summary: Member variable 'B' is initialized by itself.

Summary: Member variable 'C' is initialized by itself.

class Foo
{
public:
    Foo(int A, int B, int C);
private:
    int A;
    int B;
    int C;
}

Foo::Foo(int A, int B, int C) : 
A(A),
B(B),
C(C)
{}

I know that this is not good practice and should probably be changed, however I would like to know if the static analysis warning is a false positive and the member variables would be initialized correctly.

3 Answers
Related