使用bool類型定義變量時,編譯出錯。錯誤信息顯示如下:
'bool' undeclared (first use in this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
C語言(或C++)里本身沒有bool這種布爾類型。有些編譯器可以識別,那也是因為編譯器自己定義了bool類型,比如:#define bool int。
C語言里,一般用整型變量來實現布爾型變量的功能。當用條件語句,如if,進行判斷時,值為0時返回false,其它都返回true。
|