QtDesignPatterns/adapterpattern/first_interface.h

39 lines
784 B
C
Raw Normal View History

2024-02-06 17:21:37 +08:00
#include <string>
#include <iostream>
using namespace std;
class AdvancedMediaPlayer
{
public:
AdvancedMediaPlayer(){}
virtual ~AdvancedMediaPlayer(){}
virtual void playVlc(string fileName) = 0;
virtual void playMp4(string fileName) = 0;
};
class VlcPlayer: public AdvancedMediaPlayer
{
public:
void playVlc(string fileName)
{
cout << "Playing vlc file. Name: " + fileName << endl;
}
void playMp4(string fileName)
{
cout << fileName + " do nothing" << endl;
}
};
class Mp4Player: public AdvancedMediaPlayer
{
public:
void playVlc(string fileName)
{
cout << fileName + " do nothing" << endl;
}
void playMp4(string fileName)
{
cout << "Playing mp4 file. Name: " + fileName << endl;
}
};