?? 2-2.cc
字號:
#include <iostream.h>class car{public: car(); void printdata(); void printweight(); void printtopspeed();private: int length; int width; int horsepower;};car::car(){ cout<<"define the car's length!\n:"; cin>>this->length; cout<<"define the car's width!\n:"; cin>>this->width; cout<<"define the car's horsespeed!\n:"; cin>>this->horsepower;}void car::printdata(){ cout<<"\nthis is the car's data:\n"; cout<<"\nLength:"<<this->length; cout<<"\nWidth:"<<this->width; cout<<"\nHorse Power:"<<this->horsepower; cout<<"\n";}void car::printweight(){ cout<<"Weight:"<<(this->length*this->width*100);}void car::printtopspeed(){ if(this->horsepower <= 200) { cout<<"\nTop Speed:"<<(this->horsepower*1.2)<<"\n"; } if(this->horsepower > 200) { cout<<"\nTop Speed:"<<(this->horsepower*0.8)<<"\n"; }}main(){ car a_car; a_car.printdata(); a_car.printweight(); a_car.printtopspeed();}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -