学习Essential C++时遇到String声明问题(50分)

  • 主题发起人 YoungSun
  • 开始时间
Y

YoungSun

Unregistered / Unconfirmed
GUEST, unregistred user!
我在学习Essential C++时,即使#include <string.h>,声明string变量时仍然出错,说
String没有定义。我用的编译器是BC++3.1和Bloodshed Dev-C++4。请问是什么原因?
 
没有string这么个类,你要自己实现,vc中的CString也是自己实现的.我写了一个简单的,你如果需要,留下email
 
这样就可以了:
#include <string> //不是 include <string.h> 后面紧跟着
using namespace std;
 
goldenstone朋友,还是不行呀,麻烦你再看一下好吗?
下面是我的代码:
#include <iostream.h>
#include <string>
using namespace std;
int main()
{
string user_name;
cout << "Please enter your name:";
cin >> user_name;
cout << "Hello, " << user_name << "!/n";
}
 
谢谢goldenstone,我照你的指点解决问题了。前一个贴子是因为用的Dev-C++的问题。
 

Similar threads

顶部