-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray.h
More file actions
executable file
·51 lines (38 loc) · 1.04 KB
/
Array.h
File metadata and controls
executable file
·51 lines (38 loc) · 1.04 KB
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
// Array.h
#ifndef ARRAY_H
#define ARRAY_H
#include <iostream>
class Array
{
public:
// Default constructor
Array();
// Nondefault constructor
Array(int aLen);
// Copy constructor
Array(const Array & other);
// Assign operator
Array & operator=(const Array & other);
// Destructor
~Array();
void input(std::istream & s = std::cin);
void output(std::ostream & s = std::cout) const;
const int & operator[](int which) const;
int & operator[](int which);
int length() const;
protected:
void setLength(int aLen);
private:
int * mA;
int mLen;
void allocate(int aLen);
void copy(const Array & other);
void cleanup();
};
std::istream & operator>>(std::istream & s, Array & a);
std::ostream & operator<<(std::ostream & s, const Array & a);
bool operator==(const Array & a1, const Array & a2);
Array operator+(const Array & a1, const Array & a2);
Array operator+(const Array & a1, int x);
Array operator+( int x, const Array & a2);
#endif