可以在 C++ 中将类声明为静态吗? [英] Can a class be declared static in c++?

查看:44
本文介绍了可以在 C++ 中将类声明为静态吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这在 C++ 中是否合法(是的,我知道它在 .net 中是合法的),如果是,如何/为什么要使用它?

Is this legal in c++ (yes i know it's legal in .net), and if so, how/why would it be used?

static class foo{  
    public:  
        foo();  
        int doIt(int a);   
};

推荐答案

如果您使用的是 C++/CLI,static 的实际语法是

If you're using C++/CLI, the actual syntax for static is

ref class Foo abstract sealed /* abstract sealed = C# static */
{
};

这篇关于可以在 C++ 中将类声明为静态吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆