私人建筑商 [英] private constructors
本文介绍了私人建筑商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人能解释一下c ++中私有构造函数的确切用法吗?
Can anyone explain to me the exact use of private constructors in c++ ?
推荐答案
Preets ha scritto:
Preets ha scritto:
任何人都可以向我解释c ++中私有构造函数的确切用法吗?
Can anyone explain to me the exact use of private constructors in c++ ?
例如实现单例模式
For example for implement singleton pattern
Preets写道:
Preets wrote:
任何人都可以向我解释c ++中私有构造函数的确切用法吗?
Can anyone explain to me the exact use of private constructors in c++ ?
如果用C ++编写单例类。你将需要玩一些
技巧让所有构造函数都是私有的,包括默认,复制和
赋值运算符。
转到 http://msdn.microsoft.com/msdnmag/issues / 03/02 / CQA /
查找单例类的示例。
If you write a singleton class in C++. you will need to play some
tricks make all constructors private, including default, copy and
assignment operators.
Go to http://msdn.microsoft.com/msdnmag/issues/03/02/CQA/
to find an example of singleton class.
可以派生一个类从单身人士班?并且,可以创建该派生类的任意数量的
实例吗?
can a class derive from singleton class ? And, can any number of
instances of that derived class be created ?
这篇关于私人建筑商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文