[C++]: Multiple inheritage/Conflicts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Environment: 
GCC 4.4.0
Windows Vista
(Qt 4.6.3, FYI)


Hi,

I'm developping in Qt and I'm experiencing some compilation errors I can't
correct.

I define a class, TemporaryDbFile that is a QFile's and dbFile's derivate.

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()'

Nevertheless, this minimalist sample, representative of my concern is
accepted by the compiler:

class A {
    public:
    void close() {}
};

class B {
    public:
    virtual int close() = 0;
};


class C :public A, public B
{
public:
int close()
{
    A::close();
    return 0;
}
};


I have tested the following : to redefine void QFile::close() in my class,
TemporaryDbFile.

The compiler outputs the same compilation errors plus this one :

TemporaryDbFile.h:48:error: 'void TemporaryDbFile::close()' cannot be
overloaded

Have you some tricks for me ?

Thanks & Regards



-- 
View this message in context: http://old.nabble.com/-C%2B%2B-%3A-Multiple-inheritage-Conflicts-tp30152349p30152349.html
Sent from the gcc - Help mailing list archive at Nabble.com.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux