Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // lab2.cpp: определяет точку входа для консольного приложения.
- //
- //#include "stdafx.h"
- #include <iostream>
- using namespace std;
- class Labyrinth
- {
- int **matrix;
- int n,m;
- //вспомогательный класс для перегрузки инициализации
- class Tmp
- {
- Labyrinth &your_class;
- int i;
- Tmp(Labyrinth &your_class_, int i_): your_class(your_class_), i(i_) {}
- Tmp(const Tmp &);
- friend class Labyrinth;
- public:
- int &operator[](int j) { return your_class.matrix[i][j]; }
- };
- public:
- Labyrinth(){}; //конструктор по умолчанию
- Labyrinth(int k,int l) // конструктор с параметрами
- {
- n=k; m=l;
- matrix = new int *[n];
- for (int i=0;i<n;i++) matrix[i]=new int [m];
- }
- Labyrinth(Labyrinth & l) // конструктор копирования
- {
- //n=l.n; m=l.m;
- Labyrinth(l.n,l.m);
- for (int i;i<n;i++)
- for (int j;j<m;j++)
- matrix[i][j]=l.matrix[i][j];
- }
- //Tmp operator[](int i) { return Tmp(*this, i); } // для перегрузки индексации
- void input()
- {
- for (int i=0;i<n;i++)
- for (int j=0;j<n;j++)
- {
- cout<<"Input if there is hedge or not"<<endl;
- cin>>matrix[i][j];
- }
- }
- void show();
- int get(int i,int j)
- {
- return matrix[i][j];
- }
- Labyrinth& operator = (int x)
- {
- }
- };
- int main(int argc, char* argv[])
- {
- Labyrinth * pa;
- pa=new Labyrinth(2,2);
- //pa.input();
- pa->input();
- cout<<pa->get(1,1);
- cin.get();
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement