小编Sam*_*mer的帖子

错误:预期在“decltype”之前出现主表达式

我正在尝试查找变量的类型。在 stackoverflow 中提到了decltype()用于此目的。但是当我尝试使用它时,它会抛出我在标题中提到的错误。

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x = 4;
    cout << decltype(x);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我预料到了int,但它显示为错误。error: expected primary-expression before 'decltype'

c++ windows mingw

8
推荐指数
1
解决办法
5055
查看次数

标签 统计

c++ ×1

mingw ×1

windows ×1