CCLocalNotification 的头文件及cpp
#ifndef __CCLOCALNOTIFICATION_H_
#define __CCLOCALNOTIFICATION_H_
/*
本地消息推送管理器
*/
#include <string>
namespace cocos2d {
class CCLocalNotification
{
public:
static CCLocalNotification * shareLocalNotification();
static void destoryLocalNotification();
public:
static CCLocalNotification * m_pUniquLocalNotification;
int m_nNotifyBadgeNum;
public:
CCLocalNotification();
virtual ~CCLocalNotification();
/*
param1:消息内容
param2:消息的Key
param3:定时消息的时间戳 单位是秒
*/
virtual bool pushLocalNotifyByInterval(std::string notifyContent,int notifyKey,int timeInterval,int repeatType);
};
}
#endif
#include "CCLocalNotification.h"
namespace cocos2d {
CCLocalNotification * CCLocalNotification::m_pUniquLocalNotification=NULL;
CCLocalNotification::CCLocalNotification():m_nNotifyBadgeNum(0)
{
}
CCLocalNotification::~CCLocalNotification()
{
}
bool CCLocalNotification::init()
{
return true;
}
//////////////////////////////////////////////////////////////////////////
bool CCLocalNotification::pushLocalNotifyByInterval(std::string notifyContent,int notifyKey,int timeInterval,int repeatType)
{
return true;
}
}
CCLocalNotificationWin32 头文件及cpp ,继承CCLocalNotification
#ifndef __CCLOCALNOTIFICATIONWIN32_H__
#define __CCLOCALNOTIFICATIONWIN32_H__
#include "../../support/CCLocalNotification.h"
namespace cocos2d {
class CCLocalNotificationWin32: public CCLocalNotification
{
public:
CCLocalNotificationWin32();
virtual ~CCLocalNotificationWin32();
public:
/*
param1:消息内容
param2:消息的Key
param3:定时消息的时间戳 单位是秒
*/
virtual bool pushLocalNotifyByInterval(std::string notifyContent,int notifyKey,int timeInterval,int repeatType);
};
}
#endif
#include "CCLocalNotificationWin32.h"
namespace cocos2d {
CCLocalNotification * CCLocalNotification::shareLocalNotification()
{
if(!m_pUniquLocalNotification)
{
m_pUniquLocalNotification = new CCLocalNotificationWin32();
m_pUniquLocalNotification->init();
}
return m_pUniquLocalNotification;
}
void CCLocalNotification::destoryLocalNotification()
{
if(m_pUniquLocalNotification)
{
delete m_pUniquLocalNotification;
m_pUniquLocalNotification = NULL;
}
}
CCLocalNotificationWin32::CCLocalNotificationWin32()
{
}
CCLocalNotificationWin32::~CCLocalNotificationWin32()
{
}
/////////////////////////////////////////////////////////////////////////////////
/*
param1:消息内容
param2:消息的Key
param3:定时消息的时间戳
*/
bool CCLocalNotificationWin32::pushLocalNotifyByInterval(std::string notifyContent,int notifyKey,int timeInterval,int repeatType)
{
return true;
}
}
问题是 CCLocalNotification::shareLocalNotification() 创建的为什么会走到CCLocalNotificationWin32 的实现里面来,CCLocalNotification::shareLocalNotification()是个静态方法,
虽然在CCLocalNotification.cpp里面没有实现,不是只有纯虚函数,才需要通过派生类实现吗?求大神解惑。。
#ifndef __CCLOCALNOTIFICATION_H_
#define __CCLOCALNOTIFICATION_H_
/*
本地消息推送管理器
*/
#include <string>
namespace cocos2d {
class CCLocalNotification
{
public:
static CCLocalNotification * shareLocalNotification();
static void destoryLocalNotification();
public:
static CCLocalNotification * m_pUniquLocalNotification;
int m_nNotifyBadgeNum;
public:
CCLocalNotification();
virtual ~CCLocalNotification();
/*
param1:消息内容
param2:消息的Key
param3:定时消息的时间戳 单位是秒
*/
virtual bool pushLocalNotifyByInterval(std::string notifyContent,int notifyKey,int timeInterval,int repeatType);
};
}
#endif
#include "CCLocalNotification.h"
namespace cocos2d {
CCLocalNotification * CCLocalNotification::m_pUniquLocalNotification=NULL;
CCLocalNotification::CCLocalNotification():m_nNotifyBadgeNum(0)
{
}
CCLocalNotification::~CCLocalNotification()
{
}
bool CCLocalNotification::init()
{
return true;
}
//////////////////////////////////////////////////////////////////////////
bool CCLocalNotification::pushLocalNotifyByInterval(std::string notifyContent,int notifyKey,int timeInterval,int repeatType)
{
return true;
}
}
CCLocalNotificationWin32 头文件及cpp ,继承CCLocalNotification
#ifndef __CCLOCALNOTIFICATIONWIN32_H__
#define __CCLOCALNOTIFICATIONWIN32_H__
#include "../../support/CCLocalNotification.h"
namespace cocos2d {
class CCLocalNotificationWin32: public CCLocalNotification
{
public:
CCLocalNotificationWin32();
virtual ~CCLocalNotificationWin32();
public:
/*
param1:消息内容
param2:消息的Key
param3:定时消息的时间戳 单位是秒
*/
virtual bool pushLocalNotifyByInterval(std::string notifyContent,int notifyKey,int timeInterval,int repeatType);
};
}
#endif
#include "CCLocalNotificationWin32.h"
namespace cocos2d {
CCLocalNotification * CCLocalNotification::shareLocalNotification()
{
if(!m_pUniquLocalNotification)
{
m_pUniquLocalNotification = new CCLocalNotificationWin32();
m_pUniquLocalNotification->init();
}
return m_pUniquLocalNotification;
}
void CCLocalNotification::destoryLocalNotification()
{
if(m_pUniquLocalNotification)
{
delete m_pUniquLocalNotification;
m_pUniquLocalNotification = NULL;
}
}
CCLocalNotificationWin32::CCLocalNotificationWin32()
{
}
CCLocalNotificationWin32::~CCLocalNotificationWin32()
{
}
/////////////////////////////////////////////////////////////////////////////////
/*
param1:消息内容
param2:消息的Key
param3:定时消息的时间戳
*/
bool CCLocalNotificationWin32::pushLocalNotifyByInterval(std::string notifyContent,int notifyKey,int timeInterval,int repeatType)
{
return true;
}
}
问题是 CCLocalNotification::shareLocalNotification() 创建的为什么会走到CCLocalNotificationWin32 的实现里面来,CCLocalNotification::shareLocalNotification()是个静态方法,
虽然在CCLocalNotification.cpp里面没有实现,不是只有纯虚函数,才需要通过派生类实现吗?求大神解惑。。