实现效果如图:
代码如下:
#include <iostream>
using namespace std;
class TV
{
friend class Remote;
//默认为私有
enum{
On,Off }; //电视状态
enum{
minVol,maxVol = 100 }; //音量从0到100
enum{
minChannel = 1,maxChannel = 255 }; //频道从1到255
private:
int mState; //电视状态,开机,还是关机
int mVolume; //电视机音量
int mChannel; //电视频道
public:
TV()
{
this->mState = Off;//默认关机
this->mVolume = minVol;
this->mChannel = minChannel;
}
void onOrOff(void)
{
this->mState