|
我在做2.6章节上机时践时出现以下问题,求解答,感谢!
2.6.2运行光盘源代码问题
#include<iostream.h>
int main(void)
{
bool b;
bool a;
cin>>a;
cin>>b;
cout<<"!a="<<!a<<endl;
cout<<"a&&b : "<<(a&&b)<<endl;
cout<<"a||b :"<<(a||b)<<endl;
return 0;
}
提示如下:
--------------------Configuration: ch2_8 - Win32 Debug--------------------
Compiling...
ch2_8.cpp
e:\c++\c++光盘文件\源文件\第02章\ch2_8\ch2_8.cpp(6) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'bool' (or there is no acceptable conversion)
e:\c++\c++光盘文件\源文件\第02章\ch2_8\ch2_8.cpp(7) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'bool' (or there is no acceptable conversion)
Error executing cl.exe.
ch2_8.obj - 2 error(s), 0 warning(s)
求解.
2.6.3光盘源代码可运行,我自己输入不可运行
具体步骤:
1.Microsoft Visual C++ 6.0->file->new->win32 console application->a simple application->在文件名.cpp里面输入代码:
#include "stdafx.h"
int main(void)
{
char ch1='a';
char ch2;
int ascii;
ascii=(int)ch1;
cout<<ascii<<endl;
ch2=(char)(ascii+1);
cout<<ch2<<endl;
return 0;
}
出现以下问题,求解:
Compiling...
二点六三.cpp
e:\c++\工程代码存放\二点六三\二点六三.cpp(1) : fatal error C1083: Cannot open precompiled header file: 'Debug/二点六三.pch': No such file or directory
Error executing cl.exe.
二点六三.obj - 1 error(s), 0 warning(s) |
|