shape.cpp

来自「VC源代码大全(精华版)」· C++ 代码 · 共 56 行

CPP
56
字号
#include    <stdio.h>

class Shape
{
public:
    void Draw();
    void Show();
};

class Circle : public Shape
{
public:
    void Draw();
};

class Square : public Shape
{
public:
    void Draw();
};

void main (void)
{
Circle circle;
Square square;

    circle.Show();
    square.Show();
}

void Shape::Show()
{
    printf ("Shape::Show is used to set up the ");
    printf ("output device for drawing,\n");
    printf ("then calls Draw()\n");
    Draw();
}

void Shape::Draw()
{
    printf ("Shape::Draw ");
    printf ("draws a circle within a square\n");
}

void Circle::Draw()
{
    printf ("Circle::Draw ");
    printf ("draws only the circle\n");
}

void Square::Draw()
{
    printf ("Square::Draw ");
    printf ("draws only the square\n");
}

⌨️ 快捷键说明

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