What is the advantage of passing a object by reference?
memory consumption is less ( copy constructor is not fired) b) avoid slicing problem ( function are called based on the context of the object and not based on the type of the object) Ex: Class A; Class B:public A ; IndependentFun( A a) { a.Fun(); } void main() { B b; IndependentFun(b); } output : A::Fun() will be called ( A a = b) -> type of object is used if it was reference like IndependentFun( A& a) now the output will be B::Fun().