如何使用堆栈类型编写 class 函数

how to write a class function with type stack

我有 nodes.h 这样定义 CNode

  struct CNode
   {
      int data;
      CNode* link;
   };

然后,我有一个单独的 header 称为 queue.h,这个 class 定义有一个有趣的函数:

Class queue
{ 
public:
 .... //other functions
 CNode* front();
... //private members
};

我的工作是编写 queue.h 的实现(queue.cpp)。 因此,我的问题是:如何在实现文件中为此编写原型?

我已经尝试了这两个但没有成功:

queue::CNode* front()
{}

queue::queue CNode*::front()
{}

任何指导将不胜感激。

语法为:

CNode* queue::front()

假设 CNode 定义在 queue 之外。

如果没有 queue::,您将声明一个完全不同的全局函数。