摘要: 创建如下文件目录 :Shape.h#include //接口#ifndef Interface#define Interface struct#endif//类#ifndef Class#define Class struct#endif//SHAPE_H_#ifndef SHAPE_H_#define SHAPE_H_//抽象形状类Class Shape;typedef Class Shape * p_shape;//抽象形状类声明Class Shape{ int edge; int (*getEdge)(p_shape shape); int (*calcArea)(p_... 阅读全文
posted @ 2014-02-22 19:32 水之原 阅读(1747) 评论(2) 推荐(1) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Shape{ /** * 抽象形状类 */ public abstract class Shape { private int edge; //构造函数 public Shape(int edge) { this.edge = edge; } //抽象类实现的方法,子类可以... 阅读全文
posted @ 2014-02-22 18:18 水之原 阅读(4468) 评论(0) 推荐(0) 编辑
摘要: 如下图,先建好文件, 这里用的是Visual studio 2010当然也可以用eclipse for cpp,如下图:AbstractShape.h#ifndef ABSTRACTSHAPE_H_#define ABSTRACTSHAPE_H_/** * 抽象形状类 */class AbstractShape{private: //私有字段 int edge;public: //构造函数 AbstractShape(int edge); //实例方法,子类继承后可以重用 int getEdge(); //纯虚函数,父类没有实现,调用时只会调用子类的实... 阅读全文
posted @ 2014-02-22 17:32 水之原 阅读(1240) 评论(0) 推荐(0) 编辑
摘要: //抽象形状类 $.Class("Shape", {}, { //构造函数 init : function(edge) { this.edge = edge; }, //实例方法 getEdge : function() { return this.edge; }, //实例方法 calcArea : function() { return -1; } }); //三角形... 阅读全文
posted @ 2014-02-22 09:33 水之原 阅读(894) 评论(2) 推荐(0) 编辑