类的函数声明

时间:2018-09-19 21:24:04

标签: c++ class stack

这是上学的

我正在研究一个有关堆栈的项目。我知道如何实现这些功能,但是对于在帮助文件中声明我的功能感到困惑。我将为我的助手文件张贴标题和外壳。

#ifndef STACKARRAY_H
#define STACKARRAY_H

#include <stdexcept>
#include <iostream>

using namespace std;

#include "Stack.h"

template <typename DataType>
class StackLinked : public Stack<DataType> {

  public:

    StackLinked();
    StackLinked(const StackLinked& other);
    StackLinked& operator=(const StackLinked& other);
    ~StackLinked();

    void push(const DataType& newDataItem);
    DataType pop();

    void clear();

    bool isEmpty() const;
    bool isFull() const;

    void showStructure() const;

  private:

    class StackNode {
      public:
    StackNode(const DataType& nodeData, StackNode* nextPtr);

    DataType dataItem;
    StackNode* next;
    };

    StackNode* top;
};

#include "StackLinked.cpp"
#endif      //#ifndef STACKARRAY_H

#include <iostream>
#include <stdexcept>
using namespace std;

#include "StackLinked.h"


template <typename DataType>
StackLinked<DataType>::StackLinked() {

}



template <typename DataType>
StackLinked<DataType>::StackLinked(const StackLinked& other) {

}



template <typename DataType>
StackLinked<DataType>& StackLinked<DataType>::operator=(const StackLinked& other){

  }



template <typename DataType>
StackLinked<DataType>::~StackLinked() {

}




template <typename DataType>
StackLinked<DataType>::StackNode::StackNode(const DataType& nodeData,
                                            StackNode* nextPtr) {

}



template <typename DataType>
void StackLinked<DataType>::push(const DataType& newDataItem)
{

}



template <typename DataType>
DataType StackLinked<DataType>::pop(){

}


template <typename DataType>
void StackLinked<DataType>::clear() {



}



template <typename DataType>
bool StackLinked<DataType>::isEmpty() const{

  }





template <typename DataType>
bool StackLinked<DataType>::isFull() const {

}




template <typename DataType>
void StackLinked<DataType>::showStructure() const{



}

我只需要函数声明方面的帮助,因此我们将不胜感激!该函数也已模板化,但是我敢肯定我做的模板正确。当我仅尝试使用驱动程序文件正常编译时,会遇到一些错误。错误主要由[Function Name]组成,之前已在此处声明。

0 个答案:

没有答案
相关问题