2013-02-21 3 views
1

Я работаю в школьной лаборатории и в инструкции сказано:псевдоним, используя против ЬурейеЕ

Change the typedef that defines Word_List to a alias declaration (using)

Из того, что я гугле, способ сделать это, чтобы перейти от:

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 
+4

Что такое компилятор? –

+1

Вы включили спецификацию C++ 11 в свой проект или файл makefile? – deepmax

+0

Я добавил дополнительную информацию, отвечая на ваши вопросы. –

ответ

7

Вы можете увидеть решение здесь:

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

У вас есть ошибка конфигурации, вы не компиляции с C++ 11 спецификации.

+1

Я считаю, что g ++ поддерживает это только с версии 4.7. [test with 4.7.2] (http://liveworkspace.org/code/sgxSh$0), [test with 4.6.3] (http://liveworkspace.org/code/sgxSh$1) – 2013-02-21 16:29:24

Смежные вопросы