Category : Files from Magazines
Archive   : DDJ1291.ZIP
Filename : BOOK.ASC

 
Output of file : BOOK.ASC contained in archive : DDJ1291.ZIP
BOOKSHELF.ASC
Title: PROGRAMMER'S BOOKSHELF
Source code that accompanies Andrew Schulman's book review of
"The Standard C Library" (Plauger) and "The C++ Programming
Language, Second Edition" (Stroustrup).


Example 1: A stack template in C++ 3.0

// stack.h

template class stack
{
T *v, *p;
int sz;
public:
// all the following functions are inline
stack(int s) { v = p = new T[sz = s]; }
~stack() { delete[] v; }
void push(T a) { *p++ = a; }
T pop() { return *--p; }
int size() const { return p-v; }
}



Example 2: Creating two different classes of stack, from the same
template

#include
#include "stack.h"

main()
{
stack si(100); // stack of 100 ints
stack sc(100); // stack of 100 chars

for (int i=0; i<10; i++)
{
si.push(i);
sc.push(i);
}

while (si.size()) // pop everything and
cout << si.pop() << ' ' ; // display it
cout << '\n' ;
}


Example 3


mov bx, word ptr [si.p]
mov ax, word ptr [i]
mov word ptr [bx], ax ; *p = i
add word ptr [si.p], 2 ; p += sizeof(int)



  3 Responses to “Category : Files from Magazines
Archive   : DDJ1291.ZIP
Filename : BOOK.ASC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/