gpt4 book ai didi

c++ - 智能感知 : "count" is ambigous

转载 作者:行者123 更新时间:2023-11-30 02:26:31 24 4
gpt4 key购买 nike

#include "stdafx.h"
#include <iostream>

using namespace std;

void func(void);

static int count = 10; /* Global variable */

int main() {
while(count--) {
func();
}
return 0;
}

// Function definition
void func( void ) {
static int i = 5; // local static variable
i++;
cout << "i is " << i ;
cout << " and count is " << count << endl;
}

似乎无法解决此问题,只需学习和阅读 tutorialspoint.com 中的存储类(class)即可。这是 Visual Studio 问题吗?因为代码在 Code::Blocks 上工作

最佳答案

std 命名空间中有一个“计数”函数,因此它与您的变量发生冲突

您有多种选择: 1. 将您的变量重命名为其他名称 2. 使用“::count”而不是“count”(::表示全局命名空间而不是标准) 3. 不要做“using namespace std;”,而是在来自std的所有内容前面写上“std::”,例如:“std:cout”、“std::endl”

关于c++ - 智能感知 : "count" is ambigous,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42749314/

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