I'm a little confused about when things are copied and when they are referenced in C++. For example I have this very simple method where the arguments are references:
void setTimeSig(const int &tsNumerator, const int &tsDenominator) {
this->timeSigNum = tsNumerator;
this->timeSigDenom = tsDenominator;
}
Does this mean that because I'm using references when the function where setTimeSig
is finished, the object with the timeSigNum
and timeSigDenom
will have these two fields empty? Or is it being copied at this point: this->timeSigNum = tsNumerator;
And one more question about the same thing:
class A{
public:
B bObject;
}
B b;
A a;
a.bObject = b;
Is bObject
now referencing to b or does it contain a copy?
Any information on where or what I should read about this is much appreciated. I'm still confusing many things.