求大神帮忙,急!!!
#include<iostream>usingnamespacestd;classTV{private:boolisPowerOn;intChannel;intVolum...
#include <iostream>
using namespace std;
class TV{
private:
bool isPowerOn;
int Channel;
int Volume;
const int MAXCH;
const int MAXVO;
public:
TV(int cha=10,int vol=10):MAXCH(50),MAXVO(100)
{
isPowerOn=false;
Channel=cha;
Volume=vol;
}
void power()
{
isPowerOn=!isPowerOn;
}
void channelUp()
{
Channel++;
if(Channel>MAXCH)
Channel=0;
cout<<Channel<<endl;
void channelDown()
{
Channel--;
if(Channel<0)
Channel=MAXCH;
cout<<Channel<<endl;
}
void volumeUp()
{
Volume++;
if(Volume>MAXVO)
Volume=MAXVO;
cout<<Volume<<endl;
}
void volumeDown()
{
Volume--;
if(Volume<0)
Volume=0;
cout<<Volume<<endl;
}
void display()
{
cout<<"电视机状态"<<(power?"开机":"关机")<<endl;
cout<<"当前频道"<<Channel<<endl;
cout<<"当前音量"<<Volume<<endl;
}
};
int main()
{
TV a;
int n;
cout<<"菜单"<<endl;
cout<<"1.增加频道"<<endl;
cout<<"2.减少频道"<<endl;
cout<<"3.增加音量"<<endl;
cout<<"4.减少音量"<<endl;
cout<<"5.显示状态"<<endl;
cout<<"6.结束程序"<<endl;
cin>>n;
switch (n)
{
case 1:
a.channelUp();
break;
case 2:
a.channelDown();
break;
case 3:
a.volumeUp();
break;
case 4:
a.volumeDown();
break;
case 5:
a.display();
break;
case 6:
cout<<"false"<<endl;
break;
}
return 0;
} 展开
using namespace std;
class TV{
private:
bool isPowerOn;
int Channel;
int Volume;
const int MAXCH;
const int MAXVO;
public:
TV(int cha=10,int vol=10):MAXCH(50),MAXVO(100)
{
isPowerOn=false;
Channel=cha;
Volume=vol;
}
void power()
{
isPowerOn=!isPowerOn;
}
void channelUp()
{
Channel++;
if(Channel>MAXCH)
Channel=0;
cout<<Channel<<endl;
void channelDown()
{
Channel--;
if(Channel<0)
Channel=MAXCH;
cout<<Channel<<endl;
}
void volumeUp()
{
Volume++;
if(Volume>MAXVO)
Volume=MAXVO;
cout<<Volume<<endl;
}
void volumeDown()
{
Volume--;
if(Volume<0)
Volume=0;
cout<<Volume<<endl;
}
void display()
{
cout<<"电视机状态"<<(power?"开机":"关机")<<endl;
cout<<"当前频道"<<Channel<<endl;
cout<<"当前音量"<<Volume<<endl;
}
};
int main()
{
TV a;
int n;
cout<<"菜单"<<endl;
cout<<"1.增加频道"<<endl;
cout<<"2.减少频道"<<endl;
cout<<"3.增加音量"<<endl;
cout<<"4.减少音量"<<endl;
cout<<"5.显示状态"<<endl;
cout<<"6.结束程序"<<endl;
cin>>n;
switch (n)
{
case 1:
a.channelUp();
break;
case 2:
a.channelDown();
break;
case 3:
a.volumeUp();
break;
case 4:
a.volumeDown();
break;
case 5:
a.display();
break;
case 6:
cout<<"false"<<endl;
break;
}
return 0;
} 展开
1个回答
展开全部
void channelUp()
{
Channel++;
if(Channel>MAXCH)
Channel=0;
cout<<Channel<<endl; 《===少了个括号
void channelDown()
{
{
Channel++;
if(Channel>MAXCH)
Channel=0;
cout<<Channel<<endl; 《===少了个括号
void channelDown()
{
更多追问追答
追问
void channelUp(){Channel++;if(Channel>MAXCH)Channel=0;cout<<Channel<<endl; 《===少了个括号------》》》改正这样吗:cout<<Channel()<<endl; void channelDown(){
追答
显然应该是配对的 右 花括号啊,加在void之前,endl;之后
你的编译器应该会提示你的吧,难道你用记事本?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询