有没有办法将函数的当前状态传递给 C/C++ 中的另一个函数?我的意思是当前状态的所有参数和局部变量。例如:
void funcA (int a, int b)
{
char c;
int d, e;
// Do something with the variables.
// ...
funcB();
// Do something more.
}
void funcB()
{
// funcB() should be able to access variables a,b,c,d & e
// and any change in these variables reflect into funcA().
}
funcB()
如果需要某种功能,则代码状态不佳。但能实现吗?
如果有人开始重构具有多个参数的长方法,这会有所帮助。