我们可以定义一个静态类 [英] Can we define a static class

查看:66
本文介绍了我们可以定义一个静态类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以在类中定义一个静态成员。

但是我们可以定义一个静态类,以便所有成员都是静态的吗?

We can define a static member in a class.
But can we define a static class, so that all members are static?

推荐答案

静态类是什么意思?你是否认为Singleton模式如此

这个类只有一个实例?


-

Ajay Kalra [MVP - VC ++]
aj*******@yahoo.com

" ad" < ad@wfes.tcc.edu.tw>在消息中写道

新闻:O7 ************** @ TK2MSFTNGP10.phx.gbl ...
What do you mean by a static class? Are you thinking Singleton pattern so
that there is only one instance of this class?

--
Ajay Kalra [MVP - VC++]
aj*******@yahoo.com
"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:O7**************@TK2MSFTNGP10.phx.gbl...
我们可以定义一个静态类中的成员。
但我们可以定义静态类,以便所有成员都是静态的吗?
We can define a static member in a class.
But can we define a static class, so that all members are static?



nope ..据我所知... ...


VJ


" ad" < ad@wfes.tcc.edu.tw>在消息中写道

新闻:O7 ************** @ TK2MSFTNGP10.phx.gbl ...
nope..not as far as I know...

VJ

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:O7**************@TK2MSFTNGP10.phx.gbl...
我们可以定义一个静态类中的成员。
但我们可以定义静态类,以便所有成员都是静态的吗?
We can define a static member in a class.
But can we define a static class, so that all members are static?



AFAIK,nay ,

但您可能对此感兴趣:


公共抽象类MyClass

{

private MyClass(){}

public static void DoSomething(){...}

}


HTH,

FOR


PS:私人建筑师*很重要:)

AFAIK, nay,
but you might be interested in this:

public abstract class MyClass
{
private MyClass() { }
public static void DoSomething() { ...}
}

HTH,
F.O.R.

PS: the private constuctor *is* important :)


这篇关于我们可以定义一个静态类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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