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
|
class A
{
/*...*/
void fonctionConst1() const;
void fonctionConst2() const;
/*...*/
};
//utilisation 1
void prendRefConst(A const& a)
{
a.fonctionConst1();
a.fonctionConst2();
}
//utilisation 2
class B
{
A const& renvoiRefConst();
};
void f()
{
B objB;
A const& objA = objB.renvoiRefConst();
objA.fonctionConst1();
objA.fonctionConst2();
/*
plutot que
objB.renvoiRefConst().fonctionConst1();
objB.renvoiRefConst().fonctionConst2();
*/
} |