class lift{ private: int lift_level; int max_level; int min_level; public: lift(int max=10,int min=1,int l=5):lift_level(l),max_level( max),min_level(min){} ~lift(); bool up(int &up_level); bool down(int &down_level); int level() const {return lift_level;} }; bool lift::up(const int &up_level) { if(lift_level+up_level<=max_level){ lift_level+=up_level; return true; } else return false; } bool lift::down(const int &down_level){ if(lift_level-down_level>=min_level){ lift_level-=down_level; return true; } else return false; }
楼上的 高手 PFPF~ 也一起学习下~
Quote:求助区谢绝纯净水,下不为例!
求助区谢绝纯净水,下不为例!