有关ostream的错误,请指点
在一个类中声明:
friend ostream& operator<<(ostream& s,const Vtr& V);//输出运算符
引起如下错误:
classlib\vtr.h(46) : error C2143: syntax error : missing ';' before '&'
f:\classlib\vtr.h(46) : error C2433: 'ostream' : 'friend' not permitted on data declarations
f:\classlib\vtr.h(46) : error C2501: 'ostream' : missing storage-class or type specifiers
f:\classlib\vtr.h(46) : error C2244: 'ostream' : unable to resolve function overload
f:\classlib\vtr.h(46) : error C2061: syntax error : identifier 'ostream'
f:\classlib\vtr.h(46) : error C2501: '<<' : missing storage-class or type specifiers
f:\classlib\vtr.h(46) : error C2805: binary 'operator <<' has too few parameters
F:\ClassLib\Vtr.cpp(138) : error C2143: syntax error : missing ';' before '&'
F:\ClassLib\Vtr.cpp(138) : error C2501: 'ostream' : missing storage-class or type specifiers
F:\ClassLib\Vtr.cpp(138) : error C2061: syntax error : identifier 'ostream'
F:\ClassLib\Vtr.cpp(139) : error C2501: '<<' : missing storage-class or type specifiers
F:\ClassLib\Vtr.cpp(139) : error C2809: 'operator <<' has no formal parameters
F:\ClassLib\Vtr.cpp(140) : error C2065: 'V' : undeclared identifier
F:\ClassLib\Vtr.cpp(140) : error C2228: left of '.m_N' must have class/struct/union type
F:\ClassLib\Vtr.cpp(142) : error C2065: 's' : undeclared identifier
F:\ClassLib\Vtr.cpp(142) : error C2109: subscript requires array or pointer type
F:\ClassLib\Vtr.cpp(142) : error C2297: '<<' : illegal, right operand has type 'char [2]'
F:\ClassLib\Vtr.cpp(143) : error C2297: '<<' : illegal, right operand has type 'char [2]'
Error executing cl.exe
请指点
问题点数:20、回复次数:6Top
1 楼wjlcqjy68(众里寻她)回复于 2005-10-29 00:19:05 得分 4
using namespace std;
Top
2 楼qfeng_zhao(鱼儿鱼儿满天飞)回复于 2005-10-29 00:24:28 得分 4
还是把代码贴全吧Top
3 楼i_noname(晚九朝五)回复于 2005-10-29 00:29:40 得分 3
friend ostream& operator<<(ostream& s,const Vtr& V);//输出运算符
Vtr没声明造成Top
4 楼codearts(代码艺术)回复于 2005-10-29 00:43:50 得分 3
还是把代码贴全吧
Top
5 楼wzjall(风)回复于 2005-10-29 11:30:11 得分 3
代码Top
6 楼baiywcwttfln(A-De)回复于 2005-10-29 12:13:47 得分 3
VC6.0对<<重载支持不完全,7.0就不会了Top




