[讨论]关于头文件写法的疑惑
<P><FONT color=#ff0000>#include<iostream.h><BR></FONT>和<BR><FONT color=#3d11ee>#include<iostream> <BR>using namespace std;<BR></FONT><FONT color=#000000>这两种写法我以前用都可以的 可是最近不知道为什么我用前面的那中写法 老是会出现以下的错误提示<BR>d:\microsoft visual studio\vc98\include\streamb.h(90) : error C2027: use of undefined type 'ios'<BR> d:\microsoft visual studio\vc98\include\streamb.h(67) : see declaration of 'ios'<BR>d:\microsoft visual studio\vc98\include\streamb.h(90) : error C2061: syntax error : identifier 'seek_dir'<BR>d:\microsoft visual studio\vc98\include\istream.h(64) : error C2504: 'ios' : base class undefined<BR>d:\microsoft visual studio\vc98\include\istream.h(118) : error C2027: use of undefined type 'ios'<BR> d:\microsoft visual studio\vc98\include\streamb.h(67) : see declaration of 'ios'<BR>d:\microsoft visual studio\vc98\include\istream.h(118) : error C2061: syntax error : identifier 'seek_dir'<BR>d:\microsoft visual studio\vc98\include\istream.h(118) : error C2535: 'class istream &__thiscall istream::seekg(long)' : member function already defined or declared<BR> d:\microsoft visual studio\vc98\include\istream.h(117) : see declaration of 'seekg'<BR>d:\microsoft visual studio\vc98\include\istream.h(140) : error C2664: 'class ios &(class ios &)' : cannot convert parameter 1 from 'class istream' to 'class ios &'<BR> A reference that is not to 'const' cannot be bound to a non-lvalue<BR>d:\microsoft visual studio\vc98\include\istream.h(155) : error C2065: 'lock' : undeclared identifier<BR>d:\microsoft visual studio\vc98\include\istream.h(155) : error C2065: 'unlock' : undeclared identifier<BR>d:\microsoft visual studio\vc98\include\ostream.h(59) : error C2504: 'ios' : base class undefined<BR>d:\microsoft visual studio\vc98\include\ostream.h(95) : error C2027: use of undefined type 'ios'<BR> d:\microsoft visual studio\vc98\include\streamb.h(67) : see declaration of 'ios'<BR>d:\microsoft visual studio\vc98\include\ostream.h(95) : error C2061: syntax error : identifier 'seek_dir'<BR>d:\microsoft visual studio\vc98\include\ostream.h(95) : error C2535: 'class ostream &__thiscall ostream::seekp(long)' : member function already defined or declared<BR> d:\microsoft visual studio\vc98\include\ostream.h(94) : see declaration of 'seekp'<BR>d:\microsoft visual studio\vc98\include\ostream.h(113) : error C2664: 'class ios &(class ios &)' : cannot convert parameter 1 from 'class ostream' to 'class ios &'<BR> A reference that is not to 'const' cannot be bound to a non-lvalue<BR>d:\microsoft visual studio\vc98\include\iostream.h(83) : error C2039: 'rdbuf' : is not a member of 'iostream'<BR> d:\microsoft visual studio\vc98\include\iostream.h(66) : see declaration of 'iostream'<BR>Error executing cl.exe.</FONT></P><P><FONT color=#000000>main.obj - 15 error(s), 0 warning(s)<BR>这是为什么呢???????[em06][em06][em06][em06]</FONT></P>
<P>总会有问题的</P> 不是吧 这样解决问题 那我还是用后面那种写法算了<BR>不过那两中写法到底有没有什么区别?<BR>它们各代表什么? <P>I 在vc7里面是没有iostream.h这个文件的。所以你会出错。如果你在vc6.0里面,2个都是正确的。以后你用vc7的时候注意就是了 [em01]</P> 哦,原来这是版本不同所导致的呀!!!!我用的是VC6.0,所以这两种写法都可以。<BR>[em31][em31][em31][em34][em34][em34] <DIV class=quote><B>以下是引用<U>激情依旧</U>在2006-4-27 11:39:00的发言:</B><BR>
<P>I 在vc7里面是没有iostream.h这个文件的。所以你会出错。如果你在vc6.0里面,2个都是正确的。以后你用vc7的时候注意就是了 [em01]</P></DIV>
<P>那就怪了[em06] <BR>我一直用的是vc6.0的最近才出现这个错误的啊,好象是从我装了.net后就出现这个问题,会不会和这有关啊[em06][em06]</P> 因为iostream.h是老板本的,现在都用iostream, 恩,新旧版本不通导致的问题了
新版本不再支持后缀名了 是不是说没有后缀名的情况下都要用
using namespace std;啊?
用了这句话加后缀名似乎会出错的呢,呵呵
不太明白为什么。 是不是说没有后缀名的情况下都要用
using namespace std;啊?
用了这句话加后缀名似乎会出错的呢,呵呵
不太明白为什么。 其实第二种写法才C++的标准使用方法,在该方法中要使用using namespace std;来指定使用命名空间std,如果不写这句的话,也可以在输入输出时使用如std::cin、std::cout、std::endl等形式。
LZ说的两种方法在6.0中都是可以的,但是我使用VS2005就只能使用第二种了,MS在里面作了规范。
页:
[1]
