Adpating on old c++ book

I'm adapting code from Scott Robert Ladd's "C++ Templates and Tools". It's a very old book, and the code looks different from what I'm used to.

Here's an example that I'm having trouble with:

A Random Number Generator

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
class randgen
{
 
protected: 
	// Seem from system time
	static unsigned long TimeSeed()
	{
	return (unsigned long)time(NULL); /// This looks utterly wrong, and doesn't seem to conform to how "time" works
	}
public:
	// Constructor 
	randgen(
		unsigned long initSeed = TimeSeed()
); 
	// Set seed value 
	void SetSeed( 
		unsigned long newSeed = TimeSeed()
		); 
	// Get a psuedo-random number from 0 to (lim -1) 
	unsigned short operator ()
		( 
		unsigned short lim 
		); 

	~randgen(void);
};




and the strange implementation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
inline randgen::randgen
       (
        unsigned long initSeed
        ) 
        (
         seed = initSeed; 
        )
inline void randgen::SetSeed
        (
         unsigned long newSeed
         )
         (
          Seed = newSeed
         )




Any idea what he's trying to do? This definitely doesn't work in MSVC++.
Thanks guys!
closed account (zb0S216C)
If it's an old book, don't use it. I'm not sure what standard it's based on, but some things don't look right. Take the constructor definitions, for example: The definitions lack the parentheses, and therefore, lack the parameters. Without the parameters, the compiler will not be able to decide which constructor you're defining.

Get a new book before you pick up bad habits.

Wazzak
Topic archived. No new replies allowed.