在实际的项目过程中某个类有时候很可能我们会继承多个基类,这个时候就会容易造成冲突,但是这些基类我们又必须要使用,不可能说将冲突的基类给删掉,这个时候我们改怎么办呢?这里有一个比较简单的解决方案, 就是在这个类里面再定义一个类,让定义的这个类去继承冲突的类
下面附上实例代码:
<1> .h文件
#ifndef __IPOD_AUDIO_WINDOW_JUCEHEADER__
#define __IPOD_AUDIO_WINDOW_JUCEHEADER__
#include "JuceHeader.h"
#include "SkGUI.h"
#include "UIControl/UIHelper.hpp"
#include "Utils/SystemHelper.hpp"
#include "Utils/SysInfoHelper.hpp"
#include "UIControl/UIScrollHelper.hpp"
#include "UIControl/TitleBar.hpp"
#include "SysInfoIndexDefine.h"
#include "MsgDefine.h"
#include "SPLog.h"
#include "DriverLogger.h"
#include "iPodPublicDef.h"
#include "SkAppleAccessory.h"
class iPodAudioWindow : public CSPWindow, public ButtonListener, public ComponentListener,public ScrollBoxListener, public MultiTimer, public SliderCtrlListener
{
public:
iPodAudioWindow();
~iPodAudioWindow();
void OnStartUpdateList();
private:
class CreateSbListS:public Thread
{
public:
CreateSbListS(iPodAudioWindow& iPodwindows):m_iPodAudiowindows(iPodwindows)
{
}
void startSession()
{
startThread(0);
}
void stopSession()
{
stopThread(500);
}
void run()
{
m_iPodAudiowindows.OnStartUpdateList();
}
private:
iPodAudioWindow& m_iPodAudiowindows;
};
private:
CreateSbListS *m_CreateSbList;
BOOL m_bStopRefeshList;
};
#endif // __MAINDEMOWINDOW_JUCEHEADER__
<2>.cpp 文件 构造函数代码
iPodAudioWindow:: iPodAudioWindow()
{
m_CreateSbList = new CreateSbListS(*this);
LOG(LV_INFO, L"iPodAudioWindow : loadCtrl: Success!\n");
}