當前位置:編程學習大全網 - 編程軟體 - c++編程。(1)定義父類point,包含x和y兩個坐標屬性

c++編程。(1)定義父類point,包含x和y兩個坐標屬性

#include?<iostream>

using?namespace?std;

class?point{

public:

point(?double?x?=?0.0,?double?y?=?0.0?){

m_x?=?x;

m_y?=?y;

}

void?show(){

cout?<<?"x?=?"?<<?m_x?<<?","?<<?"y?=?"?<<?m_y?<<?endl;

}

private:

double?m_x;

double?m_y;

};

class?circle?:?public?point{

public:

circle(?double?r,?double?x?=?0.0,?double?y?=?0.0)

:?point(?x,?y){

m_r?=?r;

}

void?show(){

point::show();

cout?<<?"r?=?"?<<?m_r?<<?endl;

}

private:

double?m_r;

};

int?main()

{

circle?dc(100,20,30);

dc.show();

return?0;

}

  • 上一篇:誰知道數控機床編程分為哪些步驟
  • 下一篇:什麽是網絡菜鳥
  • copyright 2024編程學習大全網