求一个一二百行C++程序

来源:百度知道 编辑:UC知道 时间:2024/05/23 09:55:33
只要用到类就可以

class \
A \
{ \
int \
a \
; \
} \
;

把A改成B,C,...Z,就够长了。

帮别人写的
#include<iostream>
using namespace std;
class TV
{
private:
bool state;//存储电视机状态,true为开,false为关
int channel;//存储电视机频道数(0-499)
int volume;//存储电视机的音量(0-100)
public:
//无参构造函数
TV()
{
state=false;
channel=0;
volume=0;
}

//传入频道和音量的构造函数
TV(int x_channel,int x_volume)
{
state=false;
channel=x_channel;
volume=x_volume;
}

//传入状态、频道和音量的构造函数
TV(bool x_state,int x_channel,int x_volume)
{
state=x_state;
channel=x_channel;
volume=x_volume;
}

~TV();

//获取电视机状态、频道和音量
bool getState(){ return state;}
int getChannel(){ return channel;}
int getVolume(){ return volume;}

//开机
void powerOn()
{