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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
//main:
ALAN *Mon_Alan;
AL *Mon_Al;
AN *Mon_An;
Mon_Alan = new ALAN;
Mon_Al = new AL;
Mon_An = new AN;
//les classes :
class M
{
public :
M(){};
~M(){};
};
// M est la mère de ALAN !!!
// or ALAN est relié a R et P par compo bi et directionnelle ...
class ALAN: public M
{
private :
// pas visible par les fils !!!
R*m_pt_r;
P*m_pt_p;
public :
ALAN();
~ALAN();
};
ALAN:: ALAN()
{
m_pt_r= new R;
m_pt_r->set_m_pt_alan(this);
m_pt_p = new P;
}
ALAN:: ~ALAN()
{
}
// et ALAN est la mère de AL et AN
class AN : public ALAN
{
public :
AN(){};
~AN{}();
};
class AL : public ALAN
{
public :
AL(){};
~AL(){};
};
class P
{
public :
P(){};
~P(){};
};
class R
{
protected :
ALAN*m_pt_alan;
bool m_instanciation;
public :
R();
~R();
void set_m_pt_alan(ALAN*);
bool Tester_Instanciation();
bool Tester_Bidirection();
};
R:: R()
{
m_pt_alan = 0;
m_instanciation = true;
}
R:: ~R()
{
m_instanciation = false;
}
void R:: set_m_pt_alan(ALAN*m_pt_alan)
{
if (Tester_Instanciation() ==1 && Tester_Bidirection() ==0)
{
this->m_pt_alan=m_pt_alan;
}
}
bool R:: Tester_Bidirection()
{
bool test = false;
if (m_pt_alan != 0 ) test = true;
return test;
}
bool R:: Tester_Instanciation()
{
bool test = false;
if ( m_instanciation != 0 ) test = true;
return test;
} |
Partager