Código:
	#include <gpdef.h>
#include <gpstdlib.h>
#include <gpfont16.h>
#include "gpmain.h"
GPDRAWSURFACE gtSurface[2];
int giSurface;
class CRectangle {
    int x, y;
  public:
    void set_values (int,int);
    int area (void) {return (x*y);}
};
void CRectangle::set_values (int a, int b) {
  x = a;
  y = b;
}
class CRectangle2 {
    int width, height;
  public:
    CRectangle2 (int,int);
    int area (void) {return (width*height);}
};
CRectangle2::CRectangle2 (int a, int b) {
  width = a;
  height = b;
}
// Initialize graphics mode
void InitGraphics(int depth)
{
  // Initialize graphic mode
  GpGraphicModeSet(depth, NULL);
  // Crea les superficies
  GpLcdSurfaceGet(>Surface[0], 0);
  GpLcdSurfaceGet(>Surface[1], 1);
  // Register surfaces
  giSurface = 0;
  GpSurfaceSet(>Surface[giSurface]);
  // Activates LCD if needed
  if (!(GpLcdStatusGet() & GPC_LCD_ON_BIT))
    GpLcdEnable();
  giSurface = 1;
}
int divide (int a, int b=2)
{
  int r;
  r=a/b;
  return (r);
}
void prevnext (int x, int& prev, int& next)
{
  prev = x-1;
  next = x+1;
}
void GpMain (void * arg)
{
  int i, j;
  char str[30];
  CRectangle rect;
  CRectangle2 rect2 (4,6);
  
  InitGraphics(16);
  GpTextOut16(NULL, >Surface[giSurface], 0, 0, "Ejemplo C++ en 16 bits", 0);
  prevnext(1, i, j);
  gm_sprintf(str, "i=%ld, j=%ld", i, j);
  GpTextOut16(NULL, >Surface[giSurface], 0, 20, str, 0);
  i = divide(12);
  j = divide(12, 4);
  gm_sprintf(str, "i=%ld, j=%ld", i, j);
  GpTextOut16(NULL, >Surface[giSurface], 0, 40, str, 0);
  rect.set_values (3,4);
  gm_sprintf(str, "area=%ld, area2=%ld", rect.area(), rect2.area());
  GpTextOut16(NULL, >Surface[giSurface], 0, 60, str, 0);
  gm_sprintf(str, "memoria=%ld", gm_availablesize());
  GpTextOut16(NULL, >Surface[giSurface], 0, 220, str, 0);
  GpSurfaceFlip(>Surface[giSurface++]);
  giSurface &= 0x01;
  while (TRUE);
}
 Ahora voy a ver que tal los problemas de memoria con los constructores y desctructores.
Marcadores