返回列表 发帖

求助

我换成英文版的,但我做2.5时输入
#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: test - Win32 Debug--------------------
Compiling...
test.cpp
d:\代码\test\test.cpp(13) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.

test.exe - 1 error(s), 0 warning(s)
分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友

你在文件第一行写上#include   "stdafx.h" 了么?

TOP

还有bool b后面应该是分号,而不是冒号

TOP

我照你们说的改了,但还有错误
#include "stadfx.h"
#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: test - Win32 Debug--------------------
Compiling...
test.cpp
d:\代码\test\test.cpp(1) : fatal error C1083: Cannot open include file: 'stadfx.h': No such file or directory
Error executing cl.exe.

test.obj - 1 error(s), 0 warning(s)

TOP

stadfx.h  应该是stdafx。h

TOP

也错的#include "stdafx.h"
#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: test - Win32 Debug--------------------
Compiling...
test.cpp
D:\代码\test\test.cpp(7) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'bool' (or there is no acceptable conversion)
D:\代码\test\test.cpp(8) : 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.

test.exe - 2 error(s), 0 warning(s)

TOP

书上的与CD中的演示有区别:
#include <iostream.h>
int main(void)
{
        bool b;
        bool a;
        cin>>a;——————应为a=true;
        cin>>b;——————应为b=false;
        cout<<"!a="<<!a<<endl;
        cout<<"a&&b"<<(a&&b)<<endl;
        cout<<"a||b"<<(a||b)<<endl;
        return 0;
改了之后我的VC才通过

TOP

返回列表