All pastes #424917 Raw Edit

Someone

public text v1 · immutable
·published 2007-04-05 02:43 UTC
rendered paste body
g++ -o stack stack.cpp
In file included from stack.cpp:2:
stack.h:8: error: field `NextNode' has incomplete type
stack.cpp: In constructor `Node::Node(int, Node&)':
stack.cpp:13: error: `NextNode' was not declared in this scope
make: *** [stack] Error 1

\\ stack.h
class Node
{
        public:
                Node(int data, Node& next);
                int getData() const;
        private:
                int NodeData;
                Node NextNode;
};

class Stack
{
        public:
                Stack ();
                bool isEmpty();
                void push(Node next);
                Node& pop();

        private:
                Node HeadNode;

};


\\stack.cpp
#include <iostream>
#include "stack.h"


int main(){
        std::cout << "Initializing" << std::endl;
        return 0;
}

Node::Node(int data, Node& next)
{
        NodeData = data;
        NextNode = next;
}

int Node::getData() const
{
        return NodeData;
}