0

I haven't programmed in C++ in forever and am really rusty. Help me out please? I've been tasked to develop a reversible singly linked listed but the nodes have to be declared in private. How do I access them to push/pop off my stack. Or am I going about this wrong?

#include <iostream>
using namespace std;

class ReversibleStack 
{
public:
    void push(int item);
    int pop();
    bool IsEmpty();
    void Reverse();

private:
    // let's build our singly linked list in private
    typedef struct node
    {
        int first; //the first node
        node *next; //pointer to the next node available
    }node;
};

#include "ReversibleStack.h"

#include <iostream>
using namespace std;

//This is the Push function that pushes an item onto the stack
void Push(int Item)
{
    node* current = first; // sets current pointer to first
    node* new_item = Item; // sets previous pointer to NULL
    node* next = current->next; // next item in stack
}
4

1 回答 1

0

这几乎是一个语法问题。你定义这样的方法:

void ReversibleStack::Push(int Item)
{
    // ... 
}
于 2013-08-30T22:53:59.580 回答