首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

缺少类型说明符 - 假定为 int,该怎么处理

2012-03-08 
缺少类型说明符 - 假定为 int#ifndef _BST_H#define _BST_Hstruct Student{int idint passwordint score

缺少类型说明符 - 假定为 int
#ifndef _BST_H
#define _BST_H

struct Student{
int id;
int password;
int score;
string name;
};

struct BSTNode {
BSTNode* LChild;
BSTNode* RChild;
Student value;
};

1>e:\大二寒假\2\2\bst.h(8) : error C2146: 语法错误 : 缺少“;”(在标识符“name”的前面)
1>e:\大二寒假\2\2\bst.h(8) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 

不知为什么,总有这样的错误,各位大神,就解救啊

[解决办法]
加一个
#include <string>
using namespace std;
[解决办法]
可以结贴了
[解决办法]
error C2146: 语法错误 : 缺少“;”(在标识符“name”的前面)

一般都是类型未定义或者少个;什么特别符号的错误
[解决办法]
另外给点说明

头文件包含了string类的定义说明,让系统指导这个string到底代表什么东西
否则,
系统不知道这个string事什么类型,则在C中自动用int假定,而c++必须知道string是什么,则编译错
[解决办法]

探讨

加一个
#include <string>
using namespace std;

[解决办法]
探讨
加一个
#include <string>
using namespace std;

[解决办法]
因为string不是c/c++内置类型,只能加载了<string>头文件才能识别
#include <string> 加载 string头文件
using namespace std; string在命名空间:std 内
[解决办法]
探讨

加一个
#include <string>
using namespace std;

热点排行