opengl - Deleting global object in game.(C++) -


i making bubble pop game in c++ user clicks on randomly generated bubbles float screen(still in development). in order use opengl , glut game found best make bubbles global. have blank destructor not know how delete contents of bubble , create new one. tried using dynamic allocation didn't make difference. how can delete contents of bubble , make new one?

here's necessary snippet: main.cpp

bubble mybubble1; void display(void) { delete mybubble1;//error "cannot delete type bubble"  } 

my destructor here:

class bubble {    public:  //default constructor   bubble()  {       radius=(rand() % 100 )+1;      speed = rand() % 500 ;      xval = rand() % 480;      yval= -14;      islive=true;   }  ~bubble()  {   }  private:   float radius;  float speed;  float xval;  float yval;  bool islive; }; 

the code runs fine when don't try delete anything. can run infinite looping bubbles

you not using pointers in bubble destructor can stay blank. if want reassign bubble so

bubble mybubble1; //use mybubble1 ... mybubble1 = bubble(); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -