Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<cmath>
- #include<fstream>
- #include<iomanip>
- #include <vector>
- #include <algorithm>
- using namespace std;
- class Array
- {
- public:
- int n;
- int* mas;
- Array();
- Array(int* mass);
- Array(Array& M);
- void print();
- void clear();
- void razm();
- void get();
- friend istream& operator>>(istream& s, Array& a);
- friend ostream& operator<<(ostream& s, const Array& a);
- };
- istream& operator>>(istream& s, Array& a)
- {
- cout << "enter point\n";
- s >> a.x >> a.y;
- return s;
- }
- Array::Array() {
- n = 5;
- }
- Array::Array(int* mass) {
- mass = mas;
- }
- Array::Array(Array& M) {
- mas = M.mas;
- }
- void Array::get() {
- cout << "enter length ";
- cin >> n;
- int* k = new int[n];
- mas = k;
- for (int i = 0; i < n; i++) {
- cout << "enter num ";
- cin >> mas[i];
- }
- }
- void Array::print() {
- for (int i = 0; i < n; i++)
- {
- cout << mas[i] << " " << endl;
- }
- }
- void Array::razm()
- {
- cout << "razmer: " << n << endl;
- }
- void Array::clear() {
- delete[]mas;
- cout << "Массив после очищения: ";
- }
- istream& operator>>(istream& s, Array& a)
- {
- for (int i = 0; i < a.n; i++)
- {
- s >> a.mas[i];
- }
- return s;
- }
- ostream& operator<<(ostream& s, const Array& a)
- {
- for (int i = 0; i < 5; i++) {
- s << a.mas[i] << " ";
- s << endl;
- }
- return s;
- }
- int main() {
- Array a;
- Array b(a);
- int* arr;
- Array c(arr);
- c.get();
- c.print();
- c.razm();
- c.clear();
- c.print();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement