PDA

View Full Version : About inherit



nesson
8th February 2011, 07:33
Hello everyone,


I'm a newer for Qt, so pls forgiving the stupid question I asked,thanks in advance.
here is the situation :
I want to structure a class which need inherit from both class QFile and class QXmlStreamReader. then I did like this,


#ifndef STREAMMANAGER_H
#define STREAMMANAGER_H

#include <QFile>
#include <QXmlStreamReader>

class StreamManager : public QFile ,public QXmlStreamReader
{
public:


private:

};
#endif STREAMMANAGER_H


but now in main.cpp, I want open a xml file, I just don't know how to do that, as usuall, I will use QFile Object, something like "QFile *file = new QFile("/ex/ex.xml");"
, but ,how can I do now?


....
....
int main(int argc, char *argv[])
{
StreamManager *mym = new StreamManager();
return app.exec();
}


one more thing, class StreamManager is a inherited class, and I found I can't create it's own initialized function,what wrong?

Many thanks!

high_flyer
8th February 2011, 14:07
I want to structure a class which need inherit from both class QFile and class QXmlStreamReader.
You don't need multiple inheritance here.
QXmlStreamReader takes a QIODevice as parameter.