封装案例
显示立方体面积体积,及立方体是否相等
判断点与圆的关系
#include<iostream>
using namespace std;
class Club
{
private:
int m_L;
int m_W;
int m_H;
public:
void setl(int l)
{
m_L = l;
}
int getl()
{
return m_L;
}
void setw(int w)
{
m_W = w;
}
int getw()
{
return m_W;
}
void seth(int h)
{
m_H = h;
}
int geth()
{
return m_H;
}
int S()
{
return 2 * m_H * m_L + 2 * m_H * m_W + 2 * m_L * m_W;
}
int V()
{
return m_H * m_L * m_W;
}
bool sameclass(Club &c)
{
if (m_L == c.getl() && m_W == c.getw() && m_H == c.geth())
{
return true;
}
return false;
}
};
bool Same(Club &c1,Club &c2)
{
if (c1.getl() == c2.getl() && c1.getw() == c2.getw() && c1.geth() == c2.geth())
{
return true;
}
return false;
};
class point
{
private:
int m_X;
int m_Y;
public:
void setx(int x)
{
m_X = x;
}
void sety(int y)
{
m_Y = y;
}
int getx()
{
return m_X;
}
int gety()
{
return m_Y;
}
};
class circle
{
public:
void setr(int r)
{
m_R = r;
}
int getr()
{
return m_R;
}
void setcenter(point center)