C定義點類Point,圓類Circle,圓

2021-03-03 22:15:13 字數 882 閱讀 9454

1樓:

看primer 就知道了

2樓:匿名使用者

#include

using std::cout;

using std::endl;

#define pi 3.14159

struct point

virtual void show() const};struct circle : public pointdouble area() const

double perimeter() constvoid show() const

};struct cylinder : public circledouble area() const

double volume() constvoid show() const

};int main()

採用c++定義一個圓柱類(cylinder),繼承圓類(circle)。

3樓:怺逺恆暒

#include

#include

using namespace std;

#define pi 3.14159

class circle //圓類

};class cylinder:public circle //圓柱類繼承圓類

cylinder(float r,float h)//解構函式

~cylinder() {}

//radius height get set 方法void set_radius(float r)void set_height(float h)//圓柱體積方法

float volume()

};int main()

用C 寫簡單的點(Point)類

d main 中的函式名main不對,應該是display 即 include using namespace std struct point void main point a a.setxy 10.6,18.5 少了分號 a.display cout include 是包含標頭檔案是用的,這句...

在C中怎樣定義類求圓的面積,在C 中怎樣定義一個類求圓的面積?

publc areaofcircle c 定義一個類圓circle或者定義一個矩形類rectangle,分別計算它們的周長和麵積。這明顯是老師留的作業,你自己作點,大夥再幫呀,自己一點不做呀 c 程式設計題。期末考試題。建立一個circle類,有資料成員表示圓的半徑,其中有兩個方法分別求圓的面 cl...

C 類與函式的定義問題

一 thitinfo int nodeid,double hittime 值傳遞 引用傳遞 常量引用傳遞 預設常量引用傳遞 二 加const的意思是不改變形參的值,呼叫時,實參可以是const,也可以是非const...