A have a class hierarchy that looks something like this:
class AbstractDataType {
public:
virtual int getInfo() = 0;
};
class DataType: public AbstractDataType {
public:
virtual int getInfo() { };
};
class Accessor {
DataType data;
public:
const AbstractDataType& getData() const {
return(data);
}
};
Well, GCC 4.4 reports:
In the member function 'const AbstractDataType & Accessor :: getData () const: error: incorrect initialization of a link of type' const AbstractDataType & from an expression of type 'const DataType
Where am I mistaken - is this the case when I SHOULD use a pointer?
[edit - fixed half columns]
source
share