String Class Error,不能在Class中添加

Asa*_*fan 1 c++

字符串类在我的电脑中不起作用?这是我的代码,我讨厌在它上面创建一个项目,是否有任何语法错误,我的书使用的确如此,问题是什么?

#include <string>
#ifndef LAB_PROJECT_H
#define LAB_PROJECT_H


struct Node
{
  Node* nextptr;
  Node* prevptr;
  string student_name;
  string father_name;
  int registration;
  string section;
  string major;
 string area;
 };
Run Code Online (Sandbox Code Playgroud)

Alo*_*ave 5

例如,您需要使用完全限定名称string.

std::string student_name;
Run Code Online (Sandbox Code Playgroud)

  • @AsadIrfan - 不,你应该使用**完全限定的名字**`std :: string`.'using namespace std;`是令人厌恶的.它使命名空间毫无意义. (3认同)