共用方式為


編譯器警告 (層級 4) C4458

' identifier ' 宣告會隱藏類別成員

本機範圍中的識別碼 宣告 會隱藏類別範圍中同名 識別碼 的宣告。 此警告可讓您知道,此範圍中識別碼 參考會解析為本機宣告的版本,而不是類別成員版本,這可能不是您的意圖。 若要修正此問題,建議您提供與類別成員名稱不衝突的區域變數名稱。

範例

下列範例會產生 C4458,因為 中的 參數 x 和區域變數 ymember_fn 的名稱與 類別中的資料成員相同。 若要修正此問題,請針對參數和區域變數使用不同的名稱。

// C4458_hide.cpp
// compile with: cl /W4 /c C4458_hide.cpp

struct S {
    int x;
    float y;
    void member_fn(long x) {   // C4458
        double y;  // C4458
        y = x;
        // To fix this issue, change the parameter name x
        // and local name y to something that does not
        // conflict with the data member names.
    }
} s;