Suppose we are in this condition:
class C {
int a, b;
public:
C(int aa, int bb) {
setA(aa);
setB(bb);
}
void setA(int aa) { a = aa; }
int getA() { return a; }
void setB(int bb) { b = bb; }
int getB() { return b; }
C add(const C c1, const C c2);
};
If in add()
I need to access data members, which is the best way to do it? I should use the access functions set
and get
(created for the client programmer), or I can simply use data members as themself (c1.a
, c1.b
, c2.a
, c2.b
) since I am the class designer?