Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用vs-typedef的别名_C++_C++11_Alias_Typedef_Using - Fatal编程技术网

C++ 使用vs-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> #

我在一所学校的实验室工作,上面写着:

将定义Word_列表的typedef更改为别名声明(使用)

根据我在谷歌上搜索的内容,实现这一点的方法是从:

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()
{
}