此行代码在stack.cpp文件中出现错误:
array=[data,data,data]
const concurrency=3
from(array).pipe(mergeMap(request=>this.http
.post(this.url + this.saveRequestUrl, request, this.options),null,concurrency)
该错误表明变量stack::stack()
未初始化。始终初始化成员变量(类型6)。有人可以帮我理解这里的问题吗?我需要在cpp文件或头文件中解决该问题吗?应用程序是将元素压入和弹出堆栈。
stack::el
这是我的stack.h头文件
#include <iostream>
#include "Stack.h"
using namespace std;
stack::stack() //stack class constructor
{
top = -1; // start out with an empty stack represented by -1
}
stack::~stack() //destructor
{
}
bool stack::isEmpty() { //Function to determine if the stack is empty
if (top == -1) {
return true;
} else {
return false;
}
}
bool stack::isFull() { // Function to determine if the stack is full
if (top == MAX - 1) {
return true;
} else {
return false;
}
}
void stack::push(el_t elem) { //Function to push an element onto the top of the stack
if (isFull()) {
// lookup exception handling document
}
else {
top++; el[top] = elem;
cout << elem << " pushed onto the stack" << endl;
}
}
void stack::pop(el_t& elem) { //Function to pop the top element from the stack, using pass by reference
if (isEmpty()) {
//underflow exception handling
} else {elem = el[top]; top--;}
}
void stack::displayAll() //Function to display all elements in the stack
{
if (isEmpty()) {
cout << "Stack is empty" << endl;
}
else {
for (int i = top; i >= 0; i--)
cout << el[i] << endl;
}
}
void stack::topElem(el_t& elem) //Function to get the top element of a stack
{
if (isEmpty()) {
//underflow exception handling
}
else {
elem = el[top];
}
}
void stack::clearIt()
{
el_t temp = 'a';
cout << "Clearing the stack..." << endl;
while (!isEmpty()) {
pop(temp);
}
}