Error: ‘false’ undeclared (first use in this function)
When you knock the code with DEVC + +, you will report an error to the following program
bool ok(int t){
//Determine whether the tth person's job is assigned or not; if it is not assigned then a[j] = 0, otherwise a[j] = 1.
int i;
for(i=0;i<t;i++)
if(a[i]==a[t])
return false;
return true;
}
analysis:
There are no these keywords in real C. There is no keyword bool in C and early C + +. Bool can be used, but bool is not a built-in type. It is defined through typedef or macros. It is usually defined as int type. Later, the built-in type bool appeared in C + +, and the values can only be true (1) and false (0).
Solution 1:
Change the file type to CPP
Solution 2:
Macro definition of bool:
typedef enum __bool { false = 0, true = 1, } bool;
Read More:
- [Solved] error: ‘IEEE80211_BAND_2GHZ’ undeclared here (not in a function)
- QT Error: use of undeclared identifier [How to Solve]
- [Solved] Android Studio Error: Use of undeclared identifier ‘cv‘
- [How to Fix]Type error: must use keyword argument for key function
- Type error: must use keyword argument for key function
- QT solves error: use of deleted function and is private within this context
- [Solved] Eval Error: Uncaught ReferenceError: False is not defined
- [Solved] Vscode Katex Error: ParseError: KaTeX Parse Error: Can‘t Use Function ‘$‘ In Math Mode At Position …
- C++ Use of deleted function error
- R language Use setwd() function Error [How to Solve]
- [Solved] The “QtRunWork“ task returned false but did not log an error
- MFC:: error C2065: “IDD_DIALOG1”: undeclared identifier Sending and handling custom messages in MFC threads
- Tidb2.1 reports Error statement count 5001 exceeded the transaction limit, autocommit = false
- Taro Use React Hooks Error: TypeError: Object(…) is not a function
- Opencv c++ Read Video Error: capture.isOpened() Return false
- React Hook “useState“ is called in function “xxx“ which is neither a React function component or
- Error c2065: ‘QAPP’: undeclared identifier [Solved]
- Error c2065: “gwl_wndproc”: undeclared identifier [How to Solve]
- [Solved] Vs2015 error c2065: undeclared identifier error (__func__)
- [Solved] Tensorflow2.0 Error: Function call stack:distributed_function