数据结构学习(C++)——如何在一个链表中链入不同类型的对象[8]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 happycock 的 blog

【说明】直线类的定义与实现。继承shape的行为。

#ifndef listtest_h

#define listtest_h

 

#include <iostream.h>

#include "list.h"

#include "circle.h"

#include "line.h"

void listtest_mobject()

{

       list<shape*> a;

       shape *p1 = new circle;

       shape *p2 = new line;

       p1->input();

       p2->input();

       a.insert(p1);

       a.insert(p2);

       shape *p = *a.next();

       p->print();

       delete p;

       a.put(null);

       p = *a.next();

       p->print();

       delete p;

       a.put(null);

}

#endif

本文关键:数据结构 C++ 链表
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top