/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include "Radio.h"
#include "MP3.h"
#include <iostream>
int main()
{
//Button button = Button::play; //error: 'Button' was not declared in this scope, wiec nie jest tu znany enum class Button
Radio radio;
MP3 mp3;
radio.setPlayButton();
mp3.setPauseButton();
std::cout << static_cast<short>(radio.getButton())
<< std::endl
<< static_cast<short>(mp3.getButton());
return 0;
}
#ifndef HELPCLASS_H
#define HELPCLASS_H
class HelpClass
{
protected:
// friend class Radio;
//friend class MP3;
enum class Button
{
play,
pause,
stop
};
};
#endif // HELPCLASS_H
#ifndef RADIO_H
#define RADIO_H
#include "HelpClass.h"
class Radio:HelpClass
{
public:
HelpClass::Button button;
void setPlayButton()
{
button = HelpClass::Button::play;
}
HelpClass::Button getButton()
{
return button;
}
};
#endif // RADIO_H
#ifndef MP3_H
#define MP3_H
#include "HelpClass.h"
class MP3:HelpClass
{
public:
HelpClass::Button button;
void setPauseButton()
{
button = HelpClass::Button::pause;
}
HelpClass::Button getButton()
{
return button;
}
};
#endif // MP3_H