home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
CPROG
/
CGAZV5N3.ZIP
/
ARRAY.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1991-03-02
|
660b
|
23 lines
//******** Listing 6 ********************** ARRAY.HPP ****
// ARRAY.HPP : Dynamic array example rewritten using classes
// (c) C Gazette. See Listing 1 for usage.
//*******************************************************/
#ifndef ARRAY_HPP_
#define ARRAY_HPP_
#include <stdlib.h>
class dynamic_array {
int size; // remember how big it is
int* vec; // pointer to the actual data
void error(char *); // private error handler
public:
dynamic_array(size_t sz);
~dynamic_array();
int& operator[] (int index) {
if(index < 0 || index >= size) error("index out of range");
return vec[index];
}
};
#endif // ARRAY_HPP_