C++中的string应该是在头文件中,只是对C语言的的一个封装.
#include<string> using std::string; ///添加上这个或者 using namespace std;
头文件本来就无法编译啊你可以另外写个cpp文件便宜,将此头文件include 而后编译
#include using namespace std; int fun () { string abc; //调用只用就可以 }
前面应该还有#include吧.用来导入一个类库的
#include 本身不应发生错误,因为它只是嵌入一个string.h文件.c的写法,c++可用.有的编译器是 如果编译时告诉你缺了什么东西,补入就可以了.using namespace std; 是 #include #include 等 std* (标准) 头文件.#include c++ 的写法
是问怎么实现标准库中的<string>吗?如果是使用的话,直接#include <string>就可以了;
// 第一个肯定不行,string是需要using namespace std; 改这样就可以了.#include <iostream>#include <string> void SayHello(std::string); void main() { SayHello("Tom"); } void SayHello(std::string name) { std::cout<<"Good Morning! "<<name<<std::endl; } 还有头文件#include <string> 不要+.h,你现在写的是C++,不是C语言.
是的 这是 字符串 函数库 你要用他的 函数当然要有它的头文件了
没有包含string文件,加上#include 调用string是不用包含string头文件的,但是相关的重载操作还是要包含这个头文件的.