You wouldn't believe...
Apr 24, 2012 at 7:02pm UTC
I was searching my junior colleges network folders (which are open to college students) and found a copy of Borland C++ from the 1990's for DOS. Doing some further research, I found that this copy of Borland C++ was being used seriously for in-class lectures for a C++ introduction course. Here's a sample file of one of the courses solutions:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
/*------------------------------------------------------------------------*/
/* */
/* LIST.CPP */
/* */
/* Copyright Borland International 1991, 1992 */
/* All Rights Reserved */
/* */
/*------------------------------------------------------------------------*/
#if !defined( __RESOURCE_H )
#include <Resource.h>
#endif // __RESOURCE_H
#if !defined( __LIST_H )
#include <List.h>
#endif // __LIST_H
unsigned ListBlockInitializer::count = 0;
MemBlocks *List::ListElement::mgr = 0;
void List::add( Object& toAdd )
{
ListElement *newElement = new ListElement( &toAdd, head->next );
CHECK( newElement != 0 );
head->next = newElement;
itemsInContainer++;
}
List::ListElement *List::findPred( const Object& o )
{
tail->data = (Object *)&o;
ListElement *cursor = head;
while ( o != *(cursor->next->data) )
cursor = cursor->next;
tail->data = 0;
return cursor;
}
void List::detach( Object& toDetach, DeleteType dt )
{
ListElement *pred = findPred( toDetach );
ListElement *item = pred->next;
if ( delObj(dt) && pred->next != tail )
delete item->data;
pred->next = pred->next->next;
if ( item != tail )
{
itemsInContainer--;
delete item;
}
}
void List::flush( DeleteType dt )
{
ListElement *current = head->next;
while ( current != tail )
{
ListElement *temp = current;
current = current->next;
if ( delObj(dt) )
delete temp->data;
delete temp;
}
head->next = tail;
itemsInContainer = 0;
}
ContainerIterator& List::initIterator() const
{
return *( (ContainerIterator *)new ListIterator( *this ) );
}
ListIterator::~ListIterator()
{
}
ListIterator::operator int ()
{
return currentElement->next != currentElement;
}
Object& ListIterator::current()
{
return currentElement->data == 0 ? NOOBJECT : *(currentElement->data);
}
Object& ListIterator::operator ++ ( int )
{
Object *data = currentElement->data;
currentElement = currentElement->next;
return data == 0 ? NOOBJECT : *data;
}
Object& ListIterator::operator ++ ()
{
currentElement = currentElement->next;
return currentElement->data == 0 ? NOOBJECT : *(currentElement->data);
}
void ListIterator::restart()
{
currentElement = startingElement;
}
I dunno, I found it interesting... lol
Last edited on Apr 24, 2012 at 7:02pm UTC
Apr 24, 2012 at 7:03pm UTC
1 2 3
List::ListElement *List::findPred( const Object& o )
{
tail->data = (Object *)&o;
Uh?
Last edited on Apr 24, 2012 at 7:04pm UTC
Apr 24, 2012 at 7:21pm UTC
>1992
>putting header guards in source files
ISHYGDDT.
Topic archived. No new replies allowed.