我正在尝试了解代码块中的这些错误

时间:2020-02-10 02:10:45

标签: c++

    Stack::Stack(const Stack& copy)
{
    Stack temp;
    copyHelper(copy.top, temp);


}
void Stack::copyHelper(Node* top, Stack newStack) {
    if (top != nullptr)
    {
        copyHelper(top->getNext(), newStack);
        newStack.push(top->getPayload());
    }
}

我遇到了与上面的代码块有关的三个错误:

错误C2600'Stack :: Stack':无法定义编译器生成的特殊成员函数(必须首先在类中声明)Program5 C:\ Users \ tcran \ source \ repos \ Program5 \ Program5 \ Stack.cpp 14

错误C2264'Stack :: Stack':函数定义或声明错误;未调用Program5 C:\ Users \ tcran \ source \ repos \ Program5 \ Program5 \ Stack.cpp 16的函数

错误C2264'Stack :: Stack':函数定义或声明错误;未调用Program5 C:\ Users \ tcran \ source \ repos \ Program5 \ Program5 \ Stack.cpp 23的函数

有人可以详细说明为什么我会收到此错误吗?

1 个答案:

答案 0 :(得分:1)

class Stack
{
public:

  // this constructor has not been specified in your class definition.
  Stack(const Stack& copy);
};