0
基本上我试图编译一个模板类,它是为了表示一个表来添加多项式。由于这个表格需要可以为空。Turbo C++ IDE中奇怪的错误 - 类模板相关问题
这就是我想表达的那种东西http://www.mathsisfun.com/algebra/polynomials-adding-subtracting.html。
这是这是为了做到这一点的模板:
template <class T> class TableWithBlanks : public Table<T> {
public:
TableWithBlanks(const int width, const int height) : w(width), h(height), table_contents(new t_node[width][height]
{
table_contents = new t_node[width][height];
// Go through all the values and blank them.
for(int i = 0; i < w; i++)
{
for(int a = 0; a < h; a++)
{
table_contents[i][a].value_ptr = NULL;
}
}
}
void set_value(const int width, const int height, const T* table_value_ptr)
{
if(width <= w && height <= h)
{
table_contents[w][h] = table_value_ptr;
}
}
T* get_value(const int width, const int height)
{
if(width <= w && height <= h)
{
return table_contents[width][height];
}
}
private:
typedef struct node {
T* value_ptr;
} t_node;
t_node** table_contents;
int w;
int h;
};
这是我收到的错误:
[C++错误] TableWithBlanks.h(16): E2034无法转换 'TableWithBlanks ::节点 (*)[1]' 以 'TableWithBlanks ::节点 *'
PolynomialNode类是一个链接列表,其中列表中的每个节点表示一个简单多项式中的项 - 我不需要详细说明。
+1 ..........很好抓:) :) – 2010-01-07 16:16:47
谢谢 - 我没有意识到C++可能是如此不直观 – hairyyak 2010-01-07 16:36:29