关于C++的bool问题~!
bool DeliveryRequired()
{
char DelRequired;
bool boolean;
cout < < "Do you require delivery? (Y/N) ";
cin > > DelRequired;
while(toupper(DelRequired)!= 'Y ' && toupper(DelRequired)!= 'N ')
{
cout < < "Do you require delivery? (Y/N) ";
cin > > DelRequired;
}
if(DelRequired==toupper( 'Y ')) boolean=true;
else boolean=false;
return boolean;
}
void main()
{
bool DeliveryRequired()
if(boolean=true)
...................
...................
}
以上的程序是判断用户输入是否错误而且还判断输入的Y和N.如果输入Y或y就返回true,n或N就返回false;但返回方面好象出现了问题..怎么样都不能返回true,请问下应该怎么改?
[解决办法]
if(boolean=true)
改为
if(boolean==true)
[解决办法]
#include <stdlib.h>
#include <iomanip>
先包含上面这俩头文件
再写成cout < < ios::fixed < < ios::showpoint < < setprecision(2);
把那个清屏的函数用system( "cls ");来代替
你原来用的那个只能在TC下用的,VC不行
int GetUnitPrice( )
{
return 0;
}
这个函数记得返回个值
就这样了阿 这样编译就对了
SF