如:string s1("hello");
cout << s1;
这样就报错。
请指点。
谢谢。
cout << s1;
这样就报错。
请指点。
谢谢。
解决方案 »
- 虚拟打印机可以打印,实际在打印机上是无法打印
- 问一下 怎么解析一个远端xml的元素?困惑了好久了.高手解答哈..
- 用的所有控件都绑定变量好吗?
- Win32消毁窗口的问题
- 申请基础版版主!
- 戴志康: 一个23岁的年轻人 一名在读的大四学生 一个三年30万的程序员 一家中关村新创软件公司的CEO
- 我在视图区里面画图的时候会出现闪烁问题,就是已经填了颜色的那些经常会闪烁,如何解决?
- 请教一个Image2Lcd问题
- 关于WaveX 低级音频函数的一个问题
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%DEBUG和Release到底有什么区别!!!!!!!!!!!!
- 好久没来了,散分!同时,也顺道问个有点难度的问题…………
- 数据库操作延时
也不行。
报错:
F:\C++2010入门经典例题\CPrimer001\CPrimer001.cpp(11) : error C2065: 'cout' : undeclared identifier
F:\C++2010入门经典例题\CPrimer001\CPrimer001.cpp(11) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const class std::basic_string<_E,_Tr,_A> &)' : could not deduce template argument for
'class std::basic_ostream<_E,_Tr> &' from 'int'
F:\C++2010入门经典例题\CPrimer001\CPrimer001.cpp(11) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const short *)' : could not deduce template argument for 'class std::basic_ostream<_E,
_Tr> &' from 'int'
F:\C++2010入门经典例题\CPrimer001\CPrimer001.cpp(11) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const unsigned char)' : could not deduce template argument for 'class std::basic_ostre
am<_E,_Tr> &' from 'int'
F:\C++2010入门经典例题\CPrimer001\CPrimer001.cpp(11) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const unsigned char *)' : could not deduce template argument for 'class std::basic_ost
ream<_E,_Tr> &' from 'int'
F:\C++2010入门经典例题\CPrimer001\CPrimer001.cpp(11) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const signed char)' : could not deduce template argument for 'class std::basic_ostream
<_E,_Tr> &' from 'int'
F:\C++2010入门经典例题\CPrimer001\CPrimer001.cpp(11) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const signed char *)' : could not deduce template argument for 'class std::basic_ostre
am<_E,_Tr> &' from 'int'
F:\C++2010入门经典例题\CPrimer001\CPrimer001.cpp(11) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,_E)' : could not deduce template argument for 'class std::basic_ostream<_E,_Tr> &' fro
m 'int'
F:\C++2010入门经典例题\CPrimer001\CPrimer001.cpp(11) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const _E *)' : could not deduce template argument for 'class std::basic_ostream<_E,_Tr
> &' from 'int'
F:\C++2010入门经典例题\CPrimer001\CPrimer001.cpp(11) : error C2677: binary '<<' : no global operator defined which takes type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conver
sion)
执行 cl.exe 时出错.
no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no
acceptable conversion)
using namespace std;
#include <iostream>
#include <string>
using namespaace std;
为什么不行。
谢谢。
现在编译过了。
#include <string>
using namespaace std;或者是
std::cout << ...楼主要好好学习哇
#include <string>
using namespace std;
必须加上这个代码才可以用
当使用<iostream.h>时,相当于在c中调用库函数,使用的是全局命名空间,也就是早期的c++实现;c++标准为了和C区别开,也为了正确使用命名空间,规定头文件不使用后缀.h,当使用<iostream>的时候,该头文件没有定义全局命名空间,必须使用namespace std;这样才能正确使用cout。
#include <string>using namespace std;
int main(void)
{
string str("hello"); cout<<str<<endl; return 0;
}