C++ 使用vs-typedef的别名
我在一所学校的实验室工作,上面写着: 将定义Word_列表的typedef更改为别名声明(使用) 根据我在谷歌上搜索的内容,实现这一点的方法是从:C++ 使用vs-typedef的别名,c++,c++11,alias,typedef,using,C++,C++11,Alias,Typedef,Using,我在一所学校的实验室工作,上面写着: 将定义Word_列表的typedef更改为别名声明(使用) 根据我在谷歌上搜索的内容,实现这一点的方法是从: typedef vector<Word_Entry> Word_List; 大部分代码: #include <iostream> #include <algorithm> #include <list> #include <string> #include <vector> #
typedef vector<Word_Entry> 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()
{
...
}
您可以在此处看到解决方案:
#include <string>
#include <vector>
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()
{
}
#包括
#包括
使用名称空间std;
结构字输入
{
字符串ord;
无符号碳纳米管;
};
//typedef向量字列表;您是否在项目或makefile上启用了c++11规范?我已经添加了一些传统信息来回答您的问题。您是否可以发布整个文件(或具有相同错误的简化版本)?没有足够的信息来说明问题所在。使用关键字的不是只在名称空间上运行吗?我认为您不能将其用于完整的typedef。@MihaiTodor它实际上应该是这样工作的,它被称为。我相信g++只在版本4.7之后才支持它,
#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
#include <string>
#include <vector>
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()
{
}