C++ 定义类型别名时出现语法错误

C++ 定义类型别名时出现语法错误,c++,c++11,C++,C++11,在尝试定义最简单的类型别名时,出现以下错误: 语法错误:缺少“;”在第4行的“=”之前。 代码非常简单: #include "stdafx.h" #include <iostream> using namespace std; //data type aliases - using using C = char; int _tmain(int argc, _TCHAR* argv[]) { getchar(); return 0; } #包括“stdafx.h” #

在尝试定义最简单的类型别名时,出现以下错误:
语法错误:缺少“;”在第4行的“=”之前
。 代码非常简单:

#include "stdafx.h"
#include <iostream>
using namespace std;
//data type aliases - using
using C = char;
int _tmain(int argc, _TCHAR* argv[])
{
    getchar();
    return 0;
}
#包括“stdafx.h”
#包括
使用名称空间std;
//数据类型别名-使用
使用C=char;
int _tmain(int argc,_TCHAR*argv[]
{
getchar();
返回0;
}

如果使用typedef方法,则不会发生这种情况。使用
using
关键字定义类型别名的正确方式/位置是什么?为什么会发生此错误?我使用的是VS 2010 C++编译器。

< P>这是定义类型别名的正确方法。VS 2010不支持这个特性,所以你需要升级才能使用它。

你确定你的编译器版本支持类型别名吗?我用VS 2010 C++编译器。我已经更新了问题以包含这些信息。在VS2010 AFAIK中键入别名。我不知道这一点。不错的格子呢。