#include <iostream> #include <iomanip> using namespace std; class Bike { private: double speed; public: void init(int s) { speed = s; } void run() { cout<<"It is running at speed of "; cout<<speed<<endl; } void stop() { cout<<"STOP!"<<endl; } void speedUp(int s) { speed += s; } void speedDown(int s) { speed -= s; } }; int main() { Bike b1; b1.init(10); b1.run(); b1.speedUp(10); b1.run(); b1.speedDown(5); b1.run(); b1.stop(); return 0; }
初级程序员
by: Jobs 发表于:2018-04-09 21:21:39 顶(0) | 踩(0) 回复
谢谢分享
网友回复
回复芙蓉妹妹 : 客气
顶(0) 踩(0) 2018-09-12 20:35:45
回复评论