神奇的 C++
  • 板块灌水区
  • 楼主_Spectator_
  • 当前回复4
  • 已保存回复4
  • 发布时间2024/7/15 08:19
  • 上次更新2024/7/15 09:49:47
查看原帖
神奇的 C++
523641
_Spectator_楼主2024/7/15 08:19
#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。

……

2024/7/15 08:19
加载中...