Posted By: dammie () on 'CZprogram'
Title:     Dvourozmerne pole objektu v C++
Date:      Sun Jul 27 18:49:35 2003

Ahoj,

potrebuji nadefinovat a predavat dvourozmerne pole objektu, zkousel jsem neco 
(viz. program dole) ale nejak mi to nefunguje. Muze mi to nekdo prepsat do 
chodiciho tvaru? 

#include "stdafx.h"
#include <iostream.h>

// definujeme si objekt
class Bod 
{
public:
   int x;
   int y;
};

void napln(Bod **pole)
{
   for (int i = 0; i<3; i++)
   {
      for (int j = 0; i<3; i++)
      {  
         // Tady se bude neco ukladat do pole
         Bod k;
         k.y = i;
         k.x = j;
         pole[i][j] = k;

      }
   }
}


void main(int argc, char* argv[])
{

Bod **pole =  (Bod **) new Bod[3][3];

// pole 3x3 predame a naplnime
napln(pole);


// pole vytiskneme
for (int i = 0; i<3; i++)
{
   for (int j = 0; j<3; j++)
   {
      cout << pole[i][j].x << endl << pole[i][j].y << endl;
      cout << "-----------" << endl;
   }

}

}

dammie 

Search the boards