I would like to have a static const
object with some attributes set to some variable. To do this I've thought to derive the class and set the attributes in the derived class. Now I have to share the const
object with other class, but to do this I should first cast
it to the base class but I get an error.
class QAudiolib
{
private:
class DefaultAudioFormat : QAudioFormat
{
DefaultAudioFormat()
{
setByteOrder(QAudioFormat::LittleEndian);
setChannelCount(2);
setCodec("audio/pcm");
setSampleRate(44100);
setSampleSize(16);
setSampleType(QAudioFormat::SignedInt);
}
};
static const DefaultAudioFormat DEFAULT_FORMAT;
public:
QAudiolib();
static QAudioFormat getDefaultFormat()
{
return reinterpret_cast<QAudioFormat>(DEFAULT_FORMAT);
}
};
The compiler gets this error on the cast
line
error: 'QAudioFormat' is an inaccessible base of 'QAudiolib::DefaultAudioFormat'
return (QAudioFormat)(DEFAULT_FORMAT);
^
What have I to do?