When I call a constructor which assigns a passed const &
to a const &
member variable, what happens? Since a const ref
, my understanding is 'very little' - no copies, moves, constructors called, etc - just the copying of something likely to turn out to be a pointer.
E.g.
class ClassA
{
public:
ClassA(const double a):a_(a){}
const double a_;
};
class ClassB
{
const ClassA &classRef_;
public:
ClassB(const ClassA& a):classRef_(a){}
};
int main()
{
ClassA aObj(5.212);
ClassB bObj(aObj);
}
In particular, if I want to declare functions (such as here, the constructor) of ClassB
as noexcept
, what (if anything )do I need to know about ClassA
?