list - class List cfw(List Node public typedef int Data Not...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
ז ' סשת ןושח " ט 1 #ifndef __LIST_H_ // '{' // Send errors to Yechiel Kimchi (June 1998) #define __LIST_H_ // Do NOT enter again // [email protected] #include <iostream.h> #include <stdlib.h> #define DBG (0) // Set to (1) to see all function calls #if DBG #define SHOW(str) Show(str) #else #define SHOW(str) #endif #define MANUAL_EXCEPTIONS (1) // If your compiler has no exceptions #if MANUAL_EXCEPTIONS #define MY_EXCEPTION(exp, val) \ {if (!(exp)) { \ cerr << "MY_EXCEPTION: Expression " #exp " failed," \ << " for " #val " = " << val << endl \ << "\tline: " << __LINE__ << "File: " __FILE__ << endl; \ abort(); \ { { #else #define MY_EXCEPTION(exp, val) #endif List.h class List { public: typedef int Data; // Not a template, yet static void Scope() { cerr << "List::"; return;} static void Show(const char *s) { Scope(); cerr << s << endl; return;} class Iterator; class ConstIterator ; // Forward declaration private: class Node { // Everything is private - accessible to friends only Node *next; Data item; static void Scope() { List::Scope(); cerr << "Node::"; return; } static void Show(const char *s) { Scope(); cerr << s << endl; return; } friend class List; friend class Iterator; friend class ConstIterator; Node(const Data &d): next(0), item(d) { SHOW("Node(const Data&)"); } Node(const Node &n): next(0), item(n.item) { SHOW("Node(const Node&)"); } ~Node() { SHOW("~Node()"); } List.h (List & Node) Node *Next() const { SHOW("Next()"); return next; } const Data& Item() const { SHOW("Item() const"); return item; } Data& Item() { SHOW("Item()"); return item; } operator const Data&() const { SHOW("operator const Data&() const"); return item; } }; // End - class List::Node // Private services
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern