class Pet {
public:
    virtual string getDescription() const {
        return "This is Pet class";
    }
};
class Dog : public Pet {
public:
    virtual string getDescription() const {
        return "This is Dog class";
    }
};
suppose i have a function which takes argument of bas class type like
void describe(Base obj) {
   p.getDescription();
}
and i pass derived class object in this function, so the object will be sliced and we ll get output rerlated to base class.
But if i modify this function and make it like
void describe(Base& obj) {
   p.getDescription();
}
and again passes derived class object, this time output will be of derived class.
I couldnt understand how pass by reference avoides object slicing.
 
    