简体   繁体   English

布尔尚未被宣布

[英]Bool has not been declared


I have been trying to do some programming in c++ and i'm unable to understand what is the mistake here. 我一直在尝试用C ++进行一些编程,但我无法理解这里的错误。
i'm using code blocks ide and when i run the program the only error i'm getting is 我正在使用代码块 ide,当我运行程序时我得到的唯一错误

error: 'boolean' has not been declared| 错误:尚未声明“布尔值” |
||=== Build finished: 1 errors, 0 warnings (0 minutes, 0 seconds) ===|| || ===构建完成:1个错误,0个警告(0分钟,0秒)=== ||
Let me know, if you guys found any and put me in right direction. 让我知道,如果你们发现了任何东西,并向正确的方向发展。

Ok. 好。 here is the actual code. 这是实际的代码。 But i'm not yet completed fully. 但是我还没有完全完成。 i'm just halfway through. 我只是一半。

#include <iostream>

using namespace std;

bool isGoodCountry(char &countryName, int numCities, int numVillages, boolean hasNuclearPower, char &continentName, char &neighborCountries){

if(1==2){

    return false;
}
return true;

}
int main()
{
    cout << "Hello world!" << endl;

    char countryName[25];
    int numCities, numVillages;
    bool hasNuclearPower;
    char continentName[25], neighborCountries[150];

    cout<<"Enter name of the Country: ";
    cin>>countryName;

    cout<<"Enter number of cities in the country: ";
    cin>>numCities;

    cout<<"Enter number of villages in the country: ";
    cin>>numVillages;

    cout<<" Does the country has Nuclear Power: ";
    cin>>hasNuclearPower;

    cout<<"Enter name of the continent: ";
    cin>>continentName;

    cout<<"Enter the neighbor countries names: ";
    cin>>neighborCountries;

    isGoodCountry(*countryName, numCities, numVillages, hasNuclearPower, *continentName, *neighborCountries);
    return 0;
}


Thanks & regards 感谢和问候

bool isGoodCountry(char &countryName, int numCities, int numVillages, boolean hasNuclearPower, char &continentName, char &neighborCountries){

boolean isn't a type; boolean不是类型; you meant bool . 你的意思是bool

bool isGoodCountry(char &countryName, int numCities, int numVillages, bool hasNuclearPower, char &continentName, char &neighborCountries){

Should the line 应该行

bool isGoodCountry(char &countryName, int numCities, int numVillages, boolean hasNuclearPower, char &continentName, char &neighborCountries){

be

 bool isGoodCountry(char &countryName, int numCities, int numVillages, bool hasNuclearPower, char &continentName, char &neighborCountries){

instead of 代替

bool isGoodCountry(char &countryName, int numCities, int numVillages, boolean hasNuclearPower, char &continentName, char &neighborCountries)

you should write 你应该写

bool isGoodCountry(char &countryName, int numCities, int numVillages, bool hasNuclearPower, char &continentName, char &neighborCountries)

boolean is not a data type. boolean不是数据类型。 The data type is bool. 数据类型为bool。

in your if statement you write 在您的if语句中,您写

if(1==2)

this can't be possible, so the function will always return true, so why you have to use if ? 这是不可能的,所以该函数将始终返回true,那么为什么要使用if呢?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM