shape1.cpp

来自「压缩包里有教材<<C++模式设计-基于QT4开源跨平台开发框架&gt」· C++ 代码 · 共 27 行

CPP
27
字号
#include "shapes.h"#include <QString>#include <QDebug>void showNameAndArea(Shape* pshp) {    qDebug() << pshp->getName()              << " " << pshp->getDimensions()              << " area= " << pshp->area();}int main() {        Shape shp;     /* ERROR -    instantiation is not allowed on classes with    pure virtual functions */    Rectangle  rectangle(4.1, 5.2);    Square     square(5.1);    Circle     circle(6.1);    qDebug() << "This program uses hierarchies for Shapes";    showNameAndArea(&rectangle);    showNameAndArea(&circle);    showNameAndArea(&square);    return 0;}

⌨️ 快捷键说明

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