I have a class Foo which looks like this
class Foo
{
public:
    void set_bar(int val)
    {
        _bar = val;
    }
protected:
    int _bar;
};
which is inherited by class Baz which is declared as follows:
class Baz
    : public Foo
{
public:
    void set_baz(int val)
    {
        _baz = val;
    }
protected:
    int _baz;
};
and then i have a Factory class which contains a member variable of type Baz.
class Factory
{
protected:
    Baz _baz;
public:
    const Baz& get_baz() const 
    {
        return _baz;
    }
};
If I used Factory like this:
Factory f;
f.get_baz().set_bar(1);
It throws this error C2662: 'Foo::set_bar' : cannot convert 'this' pointer from 'const Baz' to 'Foo &'
 
     
     
     
     
    