我正在学校实验室工作,在说明中它说:
将定义 Word_List 的 typedef 更改为别名声明(使用)
从我用谷歌搜索的内容来看,这样做的方法是改变:
typedef vector<Word_Entry> Word_List;
至:
using Word_List = std::vector<Word_Entry>;
但是当我编译时,我收到以下错误:
error: expected nested-name-specifier before 'Word_List'
大部分代码:
#include <iostream>
#include <algorithm>
#include <list>
#include <string>
#include <vector>
#include <fstream>
#include <cctype>
#include <iomanip>
using namespace std;
struct Word_Entry
{
string ord;
unsigned cnt;
};
//typedef vector<Word_Entry> Word_List; <-This is what it used to look like
using Word_List = vector<Word_Entry>;
int main()
{
...
}
附加信息:
Yes, I am compiling with c++11
Word_Entry is a struct that stores 2 variables
I have the line "using namespace std;" in the begining of my code
I'm using mingw compiler