//
// usercenter.h
// sence
//// created by lanqs on 15-5-27.
//#ifndef __sence__usercenter__
#define __sence__usercenter__
#include
#include
usingnamespace
std;
struct userinfo //
使用者訊息儲存 ;
// 對使用者資料進行操作
class usercenter
//獲得使用者資訊
private:
static
usercenter * prect; //
靜態變數
private:
userinfo m_userinfo; //
使用者資訊 };
#endif /* defined(__sence__usercenter__) */
//// usercenter.cpp
// sence
//// created by lanqs on 15-5-27.
//// cpp實現
#include "usercenter.h"
//初始化 靜態變數
usercenter* usercenter::prect =
null;
usercenter* usercenter::getinstance()
return
prect ;
}bool
usercenter::init() //
獲取資料源
void
usercenter::refre()
//// senceone.h
// sence
//// created by lanqs on 15-5-27.
//#ifndef __sence__senceone__
#define __sence__senceone__
#include
#include
#include
#include "usercenter.h"
usingnamespace
std;
class homescence
;#endif /* defined(__sence__senceone__) */
//// senceone.cpp
// sence
//// created by lanqs on 15-5-27.
//#include "senceone.h"
void
homescence::printscen()
homescence* homescence::create() //
// main.cpp
// sence
//// created by lanqs on 15-5-27.
//#include
#include "senceone.h"
#include "secentwo.h"
#include "usercenter.h"
int main(int argc, const
char * argv)
在乙個場景裡面獲取使用者資訊
C 單例模式
include using namespace std 單例類的c 實現 class singleton 構造方法實現 singleton singleton void singleton setvar int var main int main int argc,char argv return ...
C 單例模式
實現方式一 include template typename t class singleton boost noncopyable static void init private static pthread once t ponce statict value template typena...
C 單例模式
效率有點低,但是還算安全的單例模式,靜態成員實現方式 class singleton public static singleton getinstance singleton singleton getinstance unlock return m instance 內部靜態例項的懶漢模式,c ...