Dear friends,
Could you please:
- exlain the difference in the following cases;
- tell what is the better choice of using.
Thanks in advance.
class OtherClass {
public:
void otherFunc() {};
};
//Case 1: passing an object argument with '&'
class SomeClass {
private:
OtherClass& _other;
public:
SomeClass(OtherClass& o)
: _other(o)
{}
void aFunc() {
_other.otherFunc();
}
};
//Case 2: passing an object argument with '*'
class NewClass {
private:
OtherClass* _other;
public:
NewClass(OtherClass* o)
: _other(o)
{}
void aFunc() {
_other->otherFunc();
}
};