Hello ladies and gents,
Got a question, is it wise to create a member of a class by using another class it's constructor and deleting it threw the use of that class it destructor?
For example:
// Testing code.
#include "first.h"
int main()
{
first myMenu;
bool gameLoop = true;
while (gameLoop)
{
gameLoop = false;
}
return 0;
}
#include "second.h"
class first
{
public:
first();
~first();
private:
second *mySecond;
};
#include "first.h"
first::first()
{
mySecond = new second;
}
first::~first()
{
delete mySecond;
}
class second
{
public:
second();
~second();
};
#include "second.h"
second::second() {}
second::~second() {}
Is this something that is done or should it be avoided?
Thank you.