본문 바로가기
c++

[C++] '변수(이)가 모호합니다' 오류 해결

by yoonjunho 2023. 3. 2.

 

https://cplusplus.com/reference/algorithm/count/?kw=count 

 

https://cplusplus.com/reference/algorithm/count/?kw=count

function template <algorithm> std::count template typename iterator_traits ::difference_type count (InputIterator first, InputIterator last, const T& val); Count appearances of value in range Returns the number of elements in the range [first,last) that co

cplusplus.com

namespace std에 count라는 키워드가 있다. 

그래서 std에 있는 count인지 다르게 설정한 count인지 모호하다는 뜻이다. 

 

namespace를 여러 개 사용할 때, 키워드가 중복된다면 같은 오류가 발생할 수 있다.

 

 

 

해결방법

1. 앞에 ::를 붙이면 된다. 

 

 

2. using namespace std를 사용하지 않으면 된다.

 

 

3. 다른 변수이름을 사용한다.

'c++' 카테고리의 다른 글

[C++] 공백 포함 문자열 입력 받기  (0) 2023.03.04
[C++] 입력 속도, cin속도  (0) 2023.03.02
[C++] STL - container - stack(스택)  (0) 2023.02.28
[C++] 절댓값 구하기  (0) 2023.02.27
[C++] STL - containers  (0) 2023.02.25