C++从另一个静态函数调用静态函数

发布于 2024-09-30 13:05:44 字数 673 浏览 5 评论 0原文

头文件中有一个静态函数

    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(){
}

have a static function in a header file

    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(){
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暮年慕年 2024-10-07 13:05:44

class 中的 static 意味着相关成员或方法不对对象进行操作,即它没有定义 this,但它仍在类的命名空间中。

类外部的static 的含义与C 语言中的含义相同:变量或函数没有外部链接,即当前编译单元之外的内容无法链接到它。

两种完全不同的东西。

static inside a class means that the member or method in question does not operate on an object, i.e. it doesn't define this, but it is still in the class's namespace.

static outside a class means what it means in C: the variable or function does not have external linkage, i.e. things outside the current compilation unit cannot link to it.

Two entirely different things.

夜吻♂芭芘 2024-10-07 13:05:44

我不知道问题是。
现在工作正常。最初发生在我调试时。
然后我只是执行而不是调试,工作正常。
然后我再次尝试调试,这次效果很好。

I dont know the problem was.
Works fine now. initially happened while I was debugging.
Then i just executed instead of debugging , worked fine.
then i tried debugging again , which worked fine this time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文