首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么这个简单的代码会产生语法错误?

为什么这个简单的代码会产生语法错误?
EN

Stack Overflow用户
提问于 2015-01-07 02:15:08
回答 1查看 249关注 0票数 0
代码语言:javascript
复制
#include <iostream>
using namespace std;


void fun(int i)
{
    cout<<"Called with int "<<i;
}

void main()
{
    using df = decltype(&fun);
}

我在Visual中得到以下语法错误,

代码语言:javascript
复制
Error   1   error C2143: syntax error : missing ';' before '='  c:\users\kpranit\documents\visual studio 2012\projects\sample\sample\sample.cpp 12

Error   2   error C2873: 'df' : symbol cannot be used in a using-declaration    c:\users\kpranit\documents\visual studio 2012\projects\sample\sample\sample.cpp 12
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-07 02:24:17

Visual 2012,基于您的项目目录,是您正在使用的目录,不支持类型混叠。

这是一个C++11特性,在MSDN文档中没有出现,即使是在VS2013中也是如此,尽管我认为这可能只是他们的文档错误-- 微软C++11兼容性站点 (查找“别名模板”)将其列为在VS2013下可用。

因此,如果您想使用该特性,您可能需要升级到后面的编译器。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27810446

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档