【发布时间】:2012-12-05 12:08:41
【问题描述】:
我已经定义了一个类
template <class T> class NodeMap {
NodeMap(int n, T defaultEntry = NULL);
virtual ~NodeMap();
T& operator[](const node& u);
...
}
将node 类型的对象映射到T 参数类型的对象。
现在我想要一个课程Matching,它本质上是一个NodeMap<node>。为方便起见,我想添加isProperMatching(Graph& G) 和match(node u, node v) 之类的方法。 Matching 可以继承 NodeMap<node> 吗?是否可以(如果可以,这是一个好主意)扩展具有固定模板参数的模板类吗?
【问题讨论】:
-
这很好。
NodeMap<node>是一个完全正常的类,只是它的名字拼写有点奇怪。
标签: c++ oop templates inheritance