This question is related to Tier 2 - C++
I created a separate class for Text so that I don't have to call agk functions when creating Text. Here's the simple class:
// Text.h
class Text
{
private:
int _ID;
void Destory();
public:
void AddText();
Text(int ID);
~Text();
};
Text::Destroy()
{
agk::DeleteText(_ID);
}
Text::~Text()
{
Text::Destroy();
}
Now my question is when I'm calling this class in any other class, say MainMenu, do I have to delete the button in the class MainMenu that I'm creating using this class or will the destructor of Text will automatically get called and delete the button.
// MainMenu.cpp
MainMenu::Initilization()
{
Text * mainText = new Text(1);
}
MainMenu::Destory()
{
agk::DeleteText(1); // DO I HAVE TO DO THIS?
}
MainMenu::~MainMenu()
{
MainMenu::Destory();
}
Peronally, I think deleting the button in MainMenu should be unnecessary. Please let me know if you think I'm wrong. Thanks!