#include<iostream>
int a,f(int x){return x;}
int main(){
std::cout<<f(10);
return 0;
}
结果:编译错误(a function-definition is not allowed here before '{' token)。
#include<iostream>
struct stu{
int a,f(int x){return x;}
}s;
int main(){
std::cout<<s.f(10);
return 0;
}
结果:通过编译并输出 10。
……