C++ turboc+中的奇怪错误+;IDE类模板相关问题
基本上,我正在尝试编译一个模板类,它表示一个用于相加多项式的表。因此,该表需要为空 这正是我试图表达的那种东西 这是一个模板,它的作用是:C++ turboc+中的奇怪错误+;IDE类模板相关问题,c++,C++,基本上,我正在尝试编译一个模板类,它表示一个用于相加多项式的表。因此,该表需要为空 这正是我试图表达的那种东西 这是一个模板,它的作用是: template <class T> class TableWithBlanks : public Table<T> { public: TableWithBlanks( const int width, const int height ) : w(width), h(height), table_contents( new
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;
};
模板类表格带空格:公共表格{
公众:
带空格的表格(常数整型宽度,常数整型高度):w(宽度),h(高度),表格内容(新t_节点[宽度][高度]
{
table_contents=新t_节点[宽度][高度];
//检查所有的值并将其清空。
对于(int i=0;i 如果(width在这一行中,您正在尝试动态构造一个二维数组:
table_contents = new t_node[width][height];
<>但是C++没有这样的工作。例如,如何分配二维数组,参见,例如, 在这行中,你试图动态地构造一个二维数组:
table_contents = new t_node[width][height];
<>但是C++没有这样的工作。例如,如何分配二维数组,参见,例如,/P>