/*Graph.h*/
template<typename Tv, typename Te>
class Graph
{
public:
virtual ~Graph() = 0;
/*顶点操作*/
...
/*边操作*/
...
protected:
int n; //顶点数
int e; //边数
};
#pragma once
#include "Graph.h"
#include <vector>
#include <iostream>
template<typename Tv> struct Vertex
{
...
};
template<typename Te> struct Edge
{
...
};
template<typename Tv, typename Te>
class GraphMatrix : public Graph<Tv, Te>
{
public:
...
~GraphMatrix() {
for (int i = 0; i != n; ++i)
{
for (int j = 0; j != n; ++j)
{
delete E[i][j];
}
}
}
...
};
when i Comment out virtual ~Graph() = 0;
in Graph.h, I can run the program again.
The complier said
错误 LNK2019 无法解析的外部符号 "public: virtual __thiscall Graph<char,int>::~Graph<char,int>(void)" (??1?$Graph@DH@@UAE@XZ),该符号在函数 "public: virtual __thiscall