#include "iostream"
using namespace std;
class Light
{
private:
char *color;
public:
Light();
void charge();
};
Light::Light()
{
color="Red";
}
void Light::charge()
{
cout<<color;
if(color=="Red")
color="Green";
else if(color=="Green")
color="Yellow";
else
color="Red";
}
int main( )
{
Light a;
while(1)
{
a.charge();
system("pause");
}
}
-------------------------------------
如果有理解錯誤 請告知
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.241.88