Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- class Tablica2d{
- private:
- int name;
- int width;
- int height;
- int *w;
- public:
- Tablica2d(int width, int height, int name){
- this->name = name;
- this->width = width;
- this->height = height;
- w = new int[width*height];
- }
- Tablica2d(const Tablica2d©)
- {
- name = copy.name;
- width = copy.width;
- height = copy.height;
- w = copy.w;
- }
- void read(){
- cout << name << endl;
- cout << height << endl;
- cout << width << endl;
- }
- // void readArray(int c){
- // cout << w[c]<< endl;
- // }
- void changeName(int name){
- this->name = name;
- }
- void setValue(int row, int column, int value)
- {
- int cell = row*width+column;
- this->w[cell] = value;
- }
- void readCell(int cell){
- cout << w[cell];
- }
- ~Tablica2d(){
- delete[] w;
- }
- };
- int main()
- {
- Tablica2d tablica1(2,3,1);
- Tablica2d tablica2(tablica1);
- tablica2.setValue(0,0,22);
- tablica2.readCell(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement