gpt4 book ai didi

c++ - 静态成员函数中静态变量的同名

转载 作者:行者123 更新时间:2023-11-30 00:56:10 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How are static variables with the same name in different functions identified by the System?

编译器如何区分两个同名但定义在两个不同(静态)成员函数中的局部静态变量?

class Type
{
public:
static void fun()
{
static bool sameName = false;

// work with sameName

}
static void moreFun()
{
static bool sameName = false;

// work with sameName
}
};

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com