Ver Mensaje Individual
  #3 (permalink)  
Antiguo 18/09/2011, 13:51
alexg88
 
Fecha de Ingreso: abril-2011
Mensajes: 1.342
Antigüedad: 13 años
Puntos: 344
Respuesta: Duda Con arrays, y Memory allocations.

Lo primero, mezclas calloc con new. Si estás en C++, lo mejor es usar new.

Código C++:
Ver original
  1. class point
  2. {
  3.       public:
  4.       int x;
  5.       int y;    
  6.       point (int x_,int y_){
  7.            x = x_;y = y_;
  8.            }
  9. };
  10.  
  11. class polygon
  12. {
  13.      public:
  14.      point ** points;
  15.      void set_points(int point_count, point ** new_points){
  16.           points = new point *[point_count];
  17.           int x;
  18.           for (x = 0; x < point_count;x++){
  19.               points[x] = new_points[x];
  20.               }
  21.           };
  22. };

Código C++:
Ver original
  1. int main()
  2. {
  3.     point * puntos[3];
  4.     puntos[0] = new point(5,10);
  5.     puntos[1] = new point(8,10);
  6.     puntos[2] = new point(10,10);
  7.     polygon * poligono = new polygon(); //Te falta crear el poligono con new
  8.     poligono->set_points(3,puntos);
  9.     wait(10);
  10.     return 0;  
  11. }

Como se me ha adelantado Eternal Idol, el problema es ese puntero no definido.