‡ CODING TEST STUDY ‡/º C++

[ERROR] Global variable "count" ambiguous

Trudy | 송연 2023. 11. 26. 16:57

#include <algorithm> 때문에 생기는 에러인데 

algorithm 헤더파일에는 count라는 함수가 있다. 

따라서 변수를 count를 선언하고 사용하려고 하면 count가 모호하다는 에러가 뜨는 것임

count를 cout가 아닌 다른 변수로 바꿔주면 해결 되는 문제이다. 

 

https://stackoverflow.com/questions/11271889/global-variable-count-ambiguous

 

Global variable "count" ambiguous

#include <algorithm> using namespace std; int count = 0, cache[50]; int f(int n) { if(n == 2) count++; if(n == 0 || n==1) return n; else if (cache[n] !=- 1) return cache[n];

stackoverflow.com