请教:
图中:UI-1、UI-2、UI-x是若干个用户操作
QWidget对象,COMM是一个接口对象,SOURCE是资源对象。
说明:因为所有的UI对象都通过COMM对象访问SOURCE对象。
问题:最直接的是将COMM对象定义为全局变量,所有的UI对象与之建立一个connect,对象COMM能否不定义成全局的?
学过刘典武大师的
C++单件模式:
class Singleton{
private :
static Singleton* m_pInstance;Singleton(){};
public :
static Singleton*
GetInstance(){
if(m_pInstance ==
NULL){m_pInstance =
new Singleton();}
return m_pInstance;}~Singleton(){
//delete m_pInstance; // The system goes in infinate loop here if i uncomment this m_pInstance =
NULL;}};
将对象COMM定义成单件对象,但一般的单件对象用静态类来实现,感觉也不是太好 。
请大家指点!