I am helping program a game in c++ for the Nintendo DS (It has about 3MB of RAM). For all the menus in the interface, a "button" used to be created by calling void function that sets the background tiles to a button. There are at least 30 buttons throughout the interface. Now I've created a button class that stored its position, label, along with other data values. Now my question is:
Will all these new button objects affect the RAM usage (Or other performance aspects) after the program leaves the object's scope?
Or will the object automatically be discarded once the program leaves the function it was created in?
Here is some code:
#include "Button.h"
void titlescreen() //Called to create main menu
{
Button singlePlayer = Button(4, 5, "Single Player");
//Creates button at coord (4,5)
Button multiPlayer = Button(4, 8, "Multi Player");
bool chosen = false; //Whether an option has been clicked
while(!chosen)
{
//Menu stuff here
}
}
Button.h:
#include <stdio.h>
#ifndef BUTTON_H
#define BUTTON_H
class Button
{
public:
int length;
int x, y;
bool isColored;
void setColored(bool);
void setDefault();
button(int, int, const char * const); //Constructor
button(int, int, const char * const, int); //Constructor
};
#endif /* BUTTON_H */