* arnuld:
hey, sorry, i read "Eckel's book" & came to know that /struct/ is used
to define new types. Therefore Stroustrup must have used /struct Rep/
as a declaration as he puts. anyway, i got one more problem:
in the section 2.5.1 he defines Stack /namespace/ like this:
----------------------------------------------------
namespace Stack {
cont int max_size = 200;
struct Rep {
char v[max_size];
int top;
};
const int max=16;
Rep stcks[max];
bool used[max];
typedef Rep& stack;
}
// defines Stack::push here
// defines Stack::pop
Stack::stack Stack::create()
{
// pick an unused Rep, mark it used, initialise it
// and return a reference to it
}
// defines Stack::destroy here
--------------------------------------------------------------
my trouble is: /Stack::stack Stack::create/. what work this function
is doing?
Like the comment says (and that's all I have to go on, not having the
Special Edition but just some old ones):
1. Find a currently not used element of the 'stack' array; this
element will be used to represent a new stack.
2. Initialize that element.
3. Return a reference to it (note: 'Stack::stack' is defined as a
reference type).
From the client code's view 'Stack::create' creates a new stack.
There is a problem in what 'Stack::create' should do should it fail to
find an unused element of the 'stack' array. One strategy could then be
to call 'std::terminate'. And another, to throw an exception.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?