⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shape_class.cpp

📁 本程序为visual c++课件讲义
💻 CPP
字号:
#ifndef WINDOWOBJECT_H
#define WINDOWOBJECT_H
#include "ezwin.h"

// WindowObject base class for objects that can be
// displayed in a window
class WindowObject {
    public:
        WindowObject(SimpleWindow &w, const Position &p);
        Position GetPosition() const;
        SimpleWindow& GetWindow() const;
        void SetPosition(const Position &p);
    private:
        SimpleWindwo &Window;
        Position Location;
};
#endif
==========================================================
#ifndef SHAPE_H
#define SHAPE_H
#include "windowobject.h"
// shape class derived from WindowObject class
class Shape : public WindowObject {
    public:
        Shape(SimpleWindow &w, const Position &p, const color &c = Red);
        color GetColor() const;
        void SetColor(const color &c);
    private:
        color Color;
};
#endif
==========================================================
#ifndef ELLIPSESHAPE_H
#define ELLIPSESHAPE_H
#include "shape.h"
class EllipseShape : public Shape {
    public:
        EllipseShape(SimpleWindow &Window, const Position &Center, const color &c =Red, float Length = 1.0, float Height = 2.0);
        float GetWidth() const;
        float GetHeight() const;
        void Draw();
        void SetSize(float Width, float Height);
    private:
        float Width;
        float Height;
};
#endif
==========================================================
#ifndef RECTANGLESHAPE_H
#define RECTANGLESHAPE_H
#include "shape.h"
class RectangleShape : public Shape {
    public:
        RectangleShape(SimpleWindow &Window, const Position &Center, const color &c = Red, float Width = 1.0, float Height = 2.0);
        float GetWidth() const;
        float GetHeight() const;
        void Draw();
        void SetSize(float Width, float Height);
    private:
        float Width;
        float Height;
};
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -