Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class IntArray{
- private:
- int n;
- public:
- int *a = new int;
- IntArray(int _n){
- n = _n;
- //cout << _n << endl;
- }
- friend istream & operator >> (istream &, IntArray &);
- friend ostream & operator << (ostream &, const IntArray &);
- int & operator [](int )const ;
- int size(){
- return n;
- }
- ~IntArray(){
- }
- };
- int &IntArray::operator [](int i) const
- {
- return a[i];
- }
- istream & operator >> (istream & in, IntArray & a)
- {
- int _n = a.n;
- for (auto i = 0; i < _n; ++i)
- {
- in >> a[i];
- }
- return in;
- }
- ostream & operator <<(ostream & out, const IntArray & a)
- {
- int _n = a.n;
- for (auto i = 0; i < _n; ++i)
- {
- out << a[i] << " ";
- }
- return out;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement