C++编译时报错“count”符号不明确

#include"stdafx.h"
#include 
using namespace std;
    static int count = 10;
    void func() {
    	static int i = 5;
    	i++;
    	cout << "value of i turns to " << i << ", ";
    	cout << "value of count turns to " << count << endl;
    }
    
    int main()
    {
    	while (count--)
    	{
    		func();
    	}
    	return 0;
    }

编译时全局变量count报错,符号不明确。原因是count与std::count冲突,修改变量名或限定为局部变量就可以解决。

你可能感兴趣的:(C++基础)