Brew的C++写法

myshape.h

// Shape.h: interface for the CShape class. // // #if !defined(_SHAPE_H_) #define _SHAPE_H_ #include "myColor.h" // Added by ClassView #include "AEEGraphics.h" #include "AEEShell.h" #include "AEEStdLib.h" class CShape { public: const CColor* getClr() const; CShape(CColor Clr); virtual boolean draw(IGraphics *pg) =0; CShape(); virtual ~CShape() =0; private: CColor m_Clr; }; #endif // !defined(AFX_SHAPE_H__617F9B5E_6214_4A5C_AAAF_734D718C832D__INCLUDED_)

myshape.cpp

// Shape.cpp: implementation of the CShape class. // // #include "myShape.h" // // Construction/Destruction // CShape::CShape() { } CShape::~CShape() { } CShape::CShape(CColor Clr): m_Clr(Clr) { } const CColor* CShape::getClr() const { return &m_Clr; } 

myCirc.h

// Circ.h: interface for the CCirc class. // // #if !defined(_MY_CIRC_H) #define _MY_CIRC_H #include "myShape.h" #include "myPoint.h" // Added by ClassView class CCirc : public CShape { public: void operator delete(void *p); void* operator new(size_t sz); void setr(uint16 r); void setCenter(int16 x, int16 y); void setCenter(CPoint c); CCirc(uint16 r, CPoint c, RGBVAL col); boolean draw(IGraphics *pg); uint16 getRad() const; CPoint* getCenter(); CCirc(); virtual ~CCirc(); private: uint16 m_rad; CPoint m_center; }; #endif // !defined(_MY_CIRC_H)

myCirc.cpp

// Circ.cpp: implementation of the CCirc class. // // #include "myCirc.h" // // Construction/Destruction // CCirc::CCirc() { } CCirc::~CCirc() { } CPoint* CCirc::getCenter() { return &m_center; } uint16 CCirc::getRad() const { return m_rad; } boolean CCirc::draw(IGraphics *pg) { AEECircle c; c.cx = m_center.getx(); c.cy = m_center.gety(); c.r = m_rad; boolean rval = (IGRAPHICS_DrawCircle(pg,&c) == SUCCESS); return rval; } CCirc::CCirc(uint16 r, CPoint c, RGBVAL col): CShape(CColor(col)), m_rad(r), m_center(c) { } void CCirc::setCenter(CPoint c) { m_center = c; } void CCirc::setCenter(int16 x, int16 y) { m_center = CPoint(x,y); } void CCirc::setr(uint16 r) { m_rad = r; } void* CCirc::operator new(size_t sz) { return MALLOC(sz); } void CCirc::operator delete(void *p) { FREE(p); }

myPoint.h

// Point.h: interface for the CPoint class. // // #if !defined(_POINT_H_) #define _POINT_H_ #include "AEEComDef.h" class CPoint { public: int16 gety() const; int16 getx() const; CPoint(int16 x, int16 y); CPoint(); ~CPoint(); private: int16 m_y; int16 m_x; }; #endif // !defined(_POINT_H_)

myPoint.cpp

// Point.cpp: implementation of the CPoint class. // // #include "myPoint.h" // // Construction/Destruction // CPoint::CPoint() { } CPoint::~CPoint() { } CPoint::CPoint(int16 x, int16 y): m_x(x), m_y(y) { } int16 CPoint::getx() const { return m_x; } int16 CPoint::gety() const { return m_y; }

你可能感兴趣的:(Brew的C++写法)