📄 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 + -