list_1onPage

list_1onPage - #ifndef _LIST_H_ #define _LIST_H_ #include...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
#ifndef __LIST_H_ // '{' // Send errors to Yechiel Kimchi (June 1998) #define __LIST_H_ // Do NOT enter again // yechiel@cs.technion.ac.il #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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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; { SHOW("Node(const Data&)"); } Node(const Node &n): next(0), item(n.item) { SHOW("Node(const Node&)"); } ~Node() { SHOW("~Node()"); } List.h (List & Node)
Background image of page 2
Node *Next() const { SHOW("Next()"); return next; } const Data& Item() const { SHOW("Item() const"); return item; } Data& Item() { SHOW("Item()"); return item; } { SHOW("operator const Data&() const"); return item; } }; // End - class List::Node
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/14/2011 for the course CS 234122 taught by Professor Gillbarequet during the Spring '11 term at Technion.

Page1 / 13

list_1onPage - #ifndef _LIST_H_ #define _LIST_H_ #include...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online