This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: [C++]: Multiple inheritage/Conflicts
Thanks for giving your time, Dario.
It seems it can't since 'int close()' should be public.
Could it be a gcc's bug ?
Dario Saccavino wrote:
>
> 2010/11/7 denilsson31 <denilsson31@hotmail.fr>:
>> QFile is defined like this:
>>
>> class QFile {
>> [...]
>>
>> public;
>> [...]
>>
>> virtual void close();
>>
>> [...]
>> };
>>
>> dbFile is an interface in sense of Java or pure virtual class if you
>> prefer
>> and is defined like this :
>>
>> class dbFile {
>>
>> public:
>>
>> [...]
>> virtual int close() = 0;
>>
>> [...]
>> };
>>
>> So, TemporaryDbFile has the duty to implement dbFile's interface with
>> QTemporaryFile (derivated from QFile) :
>>
>> class TemporaryDbFile :public QTemporaryFile, public dbFile
>> {
>> [...]
>>
>> 42: int close()
>> 44: {
>> 45: QTemporaryFile::close();
>> 46: return dbFile::ok;
>> 47: }
>>
>> [...]
>> }
>>
>> But in this nice picture, there is a sand grain : the gcc compiler 4.4.0.
>> He tells, mockingly :
>>
>> TemporaryDbFile.h:42:error: conflicting return type specified for
>> 'virtual
>> int TemporaryDbFile::close()'
>> C:\Qt\2010.03\qt\include\QtCore\..\..\src\corelib\io\qfile.h:148:error:
>> overriding 'virtual void QFile::close()'
>>
>> Have you some tricks for me ?
>
> You can override dbFile::close() in an intermediate class:
>
> class dbFileWrapper : public dbFile
> {
> protected:
> virtual void doClose() = 0;
> int close()
> {
> doClose();
> return dbFile::ok;
> }
> };
>
> class TemporaryDbFile : public QTemporaryFile, public dbFileWrapper
> {
> void doClose()
> {
> QTemporaryFile::close();
> }
> };
>
>
> Hope this helps.
>
> Dario
>
>
--
View this message in context: http://old.nabble.com/-C%2B%2B-%3A-Multiple-inheritage-Conflicts-tp30152349p30156383.html
Sent from the gcc - Help mailing list archive at Nabble.com.