1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| //-------- Code à ajouter dans le fichier d'en-tête de CheckNew --------
//Définition macro CHECK_NEW_MEMBER_NAME(name)
#define CHECK_NEW_MEMBER_NAME__(pfx,nm) pfx ## nm
#define CHECK_NEW_MEMBER_NAME_(pfx,nm) CHECK_NEW_MEMBER_NAME__(pfx, nm)
#define CHECK_NEW_MEMBER_NAME(name) CHECK_NEW_MEMBER_NAME_(m_, CHECK_NEW_NAME_(name))
//Définitions macros d'utilisation
#define CHECK_NEW_MEMBER_DECLARE(name) CheckNew CHECK_NEW_MEMBER_NAME(name)
#define CHECK_NEW_MEMBER_INIT(name,p) , CHECK_NEW_MEMBER_NAME(name)(p)
//-------- Exemple de code d'utilisation --------
class UseCheckNew
{
int *m_pMonEntier;
CHECK_NEW_MEMBER_DECLARE(chk1);
public:
UseCheckNew(void)
: m_pMonEntier(new int) CHECK_NEW_MEMBER_INIT(chk1, m_pMonEntier)
{
}
~UseCheckNew(void)
{
delete m_pMonEntier;
}
}; |
Partager