Notice
Recent Posts
Recent Comments
Link
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
Tags
more
Archives
Today
Total
관리 메뉴

main

[C++] warning C4804: '>': unsafe use of type 'bool' in operation 본문

C | C++

[C++] warning C4804: '>': unsafe use of type 'bool' in operation

1984 2022. 1. 30. 22:58
에러
warning C4804: '>': unsafe use of type 'bool' in operation
원인
// 잘못된 문법이다.
if(a < x < b)

// 사실상 아래와 같다.
if((a < x) < b)

// 즉 boolean < b 의 형태이므로 error 발생한다.
if (boolean < b)
해결방법
// 아래와 같이 작성한다. and operator(&&) 사용
if(a < x && x < b)

 

[참고 자료]

https://stackoverflow.com/questions/42552877/why-the-warning-c4804-unsafe-use-of-type-bool-in-operation-is-popping

728x90

'C | C++' 카테고리의 다른 글

[C++] 문자열 소문자-대문자 변환  (0) 2022.01.30
[C ++] 문자열 공백 제거  (0) 2022.01.30
Comments