lwbase.h

来自「一本全面剖析C++数据结构算法的书籍」· C头文件 代码 · 共 42 行

H
42
字号
// file lbase.h// base class for linked graph representations#ifndef LinkedBase_#define LinkedBase_#include "keychain.h"#include <iostream.h>template<class type>class LinkedBase {   public:      LinkedBase(int Vertices = 10);      ~LinkedBase() {delete [] h;}      int Edges() {return e;}      void Print();   protected:      int n; // number of vertices      int e; // number of edges      KeyedChain<type> *h; // 1D array};template<class type>LinkedBase<type>::LinkedBase(int Vertices){   n = Vertices; e = 0;   h = new KeyedChain<type> [n+1];   if (!h)    {cerr << "Out Of Memory" << endl;     exit(1);}}template<class type>void LinkedBase<type>::Print(){   for (int i = 1; i <= n; i++) {      cout << "Vertex " << i << " = ";      h[i].Print();}}#endif

⌨️ 快捷键说明

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