我一直在尝试用 c ++ 进行一些编程,我无法理解这里的错误是什么。
我正在使用代码块 ide,当我运行程序我唯一的错误是
错误:'boolean'尚未声明|
|| ===构建完成:1个错误,0个警告(0分0秒)=== ||
让我知道,如果你们发现任何并让我朝着正确的方向前进的话。
确定。这是实际的代码。但我还没有完全完成。我只是中途。
#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;
}
谢谢&amp;问候
答案 0 :(得分:5)
bool isGoodCountry(char &countryName, int numCities, int numVillages, boolean hasNuclearPower, char &continentName, char &neighborCountries){
boolean
不是一种类型;你的意思是bool
。
bool isGoodCountry(char &countryName, int numCities, int numVillages, bool hasNuclearPower, char &continentName, char &neighborCountries){
答案 1 :(得分:4)
该行
bool isGoodCountry(char &countryName, int numCities, int numVillages, boolean hasNuclearPower, char &continentName, char &neighborCountries){
是
bool isGoodCountry(char &countryName, int numCities, int numVillages, bool hasNuclearPower, char &continentName, char &neighborCountries){
答案 2 :(得分:0)
而不是
bool isGoodCountry(char &countryName, int numCities, int numVillages, boolean hasNuclearPower, char &continentName, char &neighborCountries)
你应该写
bool isGoodCountry(char &countryName, int numCities, int numVillages, bool hasNuclearPower, char &continentName, char &neighborCountries)
布尔值不是数据类型。数据类型是bool。
在您撰写的if
声明中
if(1==2)
这是不可能的,所以函数将始终返回true,那么为什么必须使用if
?