當前位置:編程學習大全網 - 編程軟體 - C++編程:用面向對象的方法求矩形面積. 要求編寫壹個矩形Rectangle類

C++編程:用面向對象的方法求矩形面積. 要求編寫壹個矩形Rectangle類

#include<iostream>

using namespace std;

class Retangle

{

public:

Retangle()

{

Length=0;

Width=0;

}

void setLW()

{

float x,y;

cout<<"input the length and width:"<<endl;

cin>>x>>y;

Length=x;

Width=y;

}

void Area()

{

cout<<"Area="<<Length*Width<<endl;

}

private:

float Length;

float Width;

};

void main()

{

Retangle abc;

abc.setLW();

abc.Area();

}

  • 上一篇:c++編程中出現“missing function header (old-style formal list?)”錯誤時什麽意思?
  • 下一篇:從寧波姜山到東裕新村公交車路線,急!
  • copyright 2024編程學習大全網