我对以下代码感到困惑:
#include <iostream>
using namespace std;
int *foo()
{
//Operation
}
int main ()
{
auto int ret = foo();
}
我在GCC下编译了上述代码,但是出现了以下错误:
error: two or more data types in declaration of 'ret'
auto int ret = foo();
但是,如果我删除int
类型,就像这样:
auto ret = foo();
然后它成功运行。
auto
是一个存储类,int
是一个数据类型,那么在第一种情况下为什么会出现“两个或多个数据类型”错误?