第乙個C 程式 造乙個簡單的類motor

2021-09-06 16:16:43 字數 781 閱讀 4867

#include

using namespace std;

//造乙個簡單的類

class motor

public:

motor(int speedt,int statust);

void motor_start(void);

void motor_speed_up(void);

void motor_status(void);

private:

int speed,status;

//定義建構函式

motor::motor(int speedt = 0,int statust = 0)

speed = speedt;

status = statust;

//定義成員函式

void motor::motor_speed_up()

if(speed <= 2000)

speed += 2;

void motor::motor_start()

status = 1;

void motor::motor_status()

cout<<"speed:"int main(void)

int temp;  

cout<<"start the motor m0 and m1"m1.motor_start();

cout<<" motor m0 speed up"cout<<"the speed of m0  is:"cout<<"the speed of m1  is:"cin>>temp;

第乙個C 程式

include using namespace std 宣告函式 void dosomething int start,int length,int center,bool order 入口 int main start 開始字元 length 字元長度 center 中間字元 order 順序還是...

第乙個c程式

include 新增必要標頭檔案 intmain 主函式,函式入口相信大部分人的第乙個c語言程式都是列印hello world!在這個函式中 第一行 是引用了乙個標準輸入輸出流的標頭檔案,這個可以說是寫 c 語言 必備的。在 c 語言中會有許多標準庫函式,這是 c 語言的開發者和許多大佬在編譯器中留...

第乙個C程式

bcpl new b c unix minix linux gcc gnu linux c語言誕生 1970年 1973年,在肯.湯普遜 丹尼斯.里奇 主 的主導下編寫完成,歸屬於美國貝爾實驗室。c語言的誕生專門用於編寫作業系統,所以天生適合硬體程式設計,也以速度快著稱,也非常適合資料結構和演算法 ...