Hi, suppose this class:
class Foo {
protected:
QPoint& bar() const;
private:
};
QPoint& Foo::bar() const {
return m_bar;
}
class Foo {
protected:
QPoint& bar() const;
private:
QPoint m_bar;
};
QPoint& Foo::bar() const {
return m_bar;
}
To copy to clipboard, switch view to plain text mode
I get this error:
error: invalid initialization of reference of type ‘QPoint&’ from expression of type ‘const QPoint’
However it works if I change it to this:
QPoint& Foo::bar() const {
return (QPoint&) m_bar;
}
QPoint& Foo::bar() const {
return (QPoint&) m_bar;
}
To copy to clipboard, switch view to plain text mode
1) I don't understand why the compiles says my QPoint is const.
2) Is it ok to leave the cast there?
Bookmarks