网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
06月04日漏签0天
c++吧 关注:617,795贴子:2,111,295
  • 看贴

  • 图片

  • 吧主推荐

  • 游戏

  • 0回复贴,共1页
<<返回c++吧
>0< 加载中...

求大神解惑 c++多态继承问题

  • 只看楼主
  • 收藏

  • 回复
  • 人走茶凉之后_
  • ,
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
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里面没有实现,不是只有纯虚函数,才需要通过派生类实现吗?求大神解惑。。


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 0回复贴,共1页
<<返回c++吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示