我的这个堆栈的构造函数作为数组实现有什么问题?
What's wrong with my constructor for this stack as array implementation?
下面的构造函数有什么问题?我收到一个错误,说:
错误1 错误 C2359:非类类型的成员需要单个初始值设定项表达式
错误 2 错误 C2359:非类类型的成员需要单个初始值设定项表达式
它说错误在第 55 行,如果您快速查看,我将下面的字体设置为粗体。
template <typename Type>
class Drop_off_stack_as_array {
private:
int itop;
int ibottom;
int entry_count;
int array_capacity;
Type *array;
public:
Drop_off_stack_as_array( int = 10 );
Drop_off_stack_as_array( Drop_off_stack_as_array const & );
~Drop_off_stack_as_array();
int size() const;
bool empty() const;
Type top() const;
bool full() const;
void swap( Drop_off_stack_as_array & );
Drop_off_stack_as_array &operator = ( Drop_off_stack_as_array );
void push( Type const & );
Type pop();
void clear();
template <typename T>
friend std::ostream &operator << ( std::ostream &, Drop_off_stack_as_array<T> const & );
};
template <typename Type>
Drop_off_stack_as_array<Type>::Drop_off_stack_as_array( int n ):
itop(0),
ibottom(0),
entry_count(0),
array_capacity(0,n),
**array(new Type[array_capacity]){**
//empty constructor
}
错误是前面的一行,在这里:
array_capacity(0,n),
应该是
array_capacity(n),
相关文章:
- 实现链表数组
- C++数组队列实现方法错误
- 如何在 c++ 中实现堆栈数组?
- 为什么在此排序算法实现中,向量明显比数组慢?
- 如何使用列表/数组在C++中实现 Python "... not in ..."?
- 类中的数组变量C++导致"was not declared in this scope"实现文件的一个函数中错误,但在构造函数中不会导致错误
- 如何实现删除数组的功能?
- 正确实现类函数数组
- 在内存中连续分配的多维数组的实现
- 在给定程序中降低矢量数组实现堆栈的时间复杂度有哪些不同的可能方法?
- 如何在本机 c++ jni 中实现 java 类型数组
- C++ 使用数组实现堆栈
- CRC32 C++使用布尔数组和手动逐位异或实现
- 使用 C++ STL 的数组实现
- 如何使用 c++ 模板实现整数、字符串、浮点数和日期对象的数组
- 使用线性存储实现2D数组
- 为自定义数组实现迭代器
- 在 C++ 中实现 1D 数组中的 2D 数组坐标
- 类成员数组的实现:数组下标的类型无效
- 在c++中实现数组