2-2.cc
来自「一个qt设计的教程」· CC 代码 · 共 61 行
CC
61 行
#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 + =
减小字号Ctrl + -
显示快捷键?