C++ C++;从另一个静态函数调用静态函数
在头文件中具有静态函数C++ C++;从另一个静态函数调用静态函数,c++,static-methods,static-functions,C++,Static Methods,Static Functions,在头文件中具有静态函数 class Diagnostics { public: static void functionA(){ } static void functionB(){ some code //works fine until enters the loop below variable_name // works fine here. if (condition){ // variable_name;
class Diagnostics {
public:
static void functionA(){
}
static void functionB(){
some code //works fine until enters the loop below
variable_name // works fine here.
if (condition){ //
variable_name; // after condition is met , i step in here, debugger cannot examine
// the vairable_name which was fine above. right after i try to step over , i get SIGSEV error
some_code; // doesnt even come here. Process exited with SIGSEV
function C(); // tried using classname::functionC , didnt work either
}
}
static void functionC(){
}
类中的静态
表示所讨论的成员或方法不在对象上操作,即它不定义此
,但仍在类的命名空间中
static
类外意味着它在C中的含义:变量或函数没有外部链接,即当前编译单元之外的东西无法链接到它
两件完全不同的事情。我不知道问题出在哪里。
现在一切正常。最初发生在我调试时。
然后我只是执行而不是调试,工作正常。
然后我再次尝试调试,这次效果很好。问题是什么?我不希望找到variable\u name
——在类定义或前面的代码中没有提到它。我看不出,如果没有编译,进程怎么会退出SIGSEGV,如果没有找到variable\u name
,它就不会退出。什么是variable\u name
?什么是一些代码?它们的定义是什么?此外,函数中缺少返回类型。请向我们显示确切的代码。变量名是非静态类成员吗?如果是这样的话,那就是你的问题。嗯,我也找不到变量名
。。也许是因为OP的代码缩进不正确,所以你感到困惑。我已经修好了,你现在应该明白为什么这个答案不起作用了。(即function C
是该类的成员)