?? integer.h
字號(hào):
// Integer.h Integer class definition
#ifndef INTEGER_H
#define INTEGER_H
#include <iostream>
using std::cout;
using std::endl;
using std::iterator;
class Integer : public iterator<std::random_access_iterator_tag, int, int, int*, int> {
public:
Integer(int n=0) : x(n) {} // Default constructor
Integer(const Integer& y) : x(y.x) {} // Copy constructor
~Integer() {} // Destructor
Integer& operator=(const Integer& y) { // Assignment operator
x = y.x;
return *this;
}
// Relational operators
bool operator==(const Integer& y) const { return x == y.x; }
bool operator!=(const Integer& y) const { return !(*this == y); }
// Delegate to operator==
bool operator<(const Integer& y) const { return x < y.x; }
int operator*() const { return x; }
int operator[](int n) const { return x+n; }
// Bidirectional operators
Integer& operator++() {
++x;
return *this;
}
Integer& operator--() {
--x;
return *this;
}
Integer& operator++(int) {
Integer temp(*this);
++x;
return temp;
}
Integer& operator--(int) {
Integer temp(*this);
--x;
return temp;
}
// Random access operators
Integer operator+(int n) const { return Integer (x+n); }
Integer operator-(int n) const { return Integer (x-n); }
private:
int x;
};
#endif // INTEGER_H
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -