#include<iostream>
using namespace std;
class binarynode
{
public:
int a;
int b;
void fun1(int n,int m)
{
fun2(n,m);
}
void fun2(int n ,int m)
{
cout<<n+m;
}
};
void fun1(int n,int m)
{
void fun2(int n ,int m);//注释掉就会报错,找不到fun2()标识符
fun2(n,m);
}
void fun2(int n ,int m)
{
cout<<n+m;
}
int main()
{
binarynode a;
a.fun1(2,3);
fun1(2,3);
system("pause");
return 0;
}
突然想到一个问题,在类中和不在类中的函数在嵌套调用时有什么不同,做了一个实验,在类中的函数嵌套调用时不必考虑函数的声明顺序,不在类中函数嵌套定义,要不就是被调用函数定义在调用者之前,要不就是在调用者函数中声明一次。
深层次的原因,有待探究