importantman
27th October 2006, 20:22
I am trying to create a QMap as a seperate .h .cpp pair because it is a really long list, but doing so generates errors.
Here is the .h
#ifndef XMLSQLMAP_H
#define XMLSQLMAP_H
#include <qmap.h>
#include <qstring.h>
QMap<QString,QString> xmlsqlmap;
#endif
and here is a beginning of the .cc
#include "xmlsqlmap.h"
xmlsqlmap["PlayerID"] = "ID";
xmlsqlmap["PlayerName"] = "Name";
and here a sample of the lovely errors that result.
xmlsqlmap.cpp:3: error: ISO C++ forbids declaration of `xmlsqlmap' with no type
xmlsqlmap.cpp:3: error: size of array `xmlsqlmap' has non-integer type
xmlsqlmap.cpp:3: error: conflicting types for `int xmlsqlmap[1]'
xmlsqlmap.h:13: error: previous declaration as `QMap<QString, QString>
xmlsqlmap'
xmlsqlmap.cpp:4: error: ISO C++ forbids declaration of `xmlsqlmap' with no type
xmlsqlmap.cpp:4: error: size of array `xmlsqlmap' has non-integer type
xmlsqlmap.cpp:4: error: redefinition of `int xmlsqlmap[1]'
can anyone tell my why this happens, and how to fix it ?
Here is the .h
#ifndef XMLSQLMAP_H
#define XMLSQLMAP_H
#include <qmap.h>
#include <qstring.h>
QMap<QString,QString> xmlsqlmap;
#endif
and here is a beginning of the .cc
#include "xmlsqlmap.h"
xmlsqlmap["PlayerID"] = "ID";
xmlsqlmap["PlayerName"] = "Name";
and here a sample of the lovely errors that result.
xmlsqlmap.cpp:3: error: ISO C++ forbids declaration of `xmlsqlmap' with no type
xmlsqlmap.cpp:3: error: size of array `xmlsqlmap' has non-integer type
xmlsqlmap.cpp:3: error: conflicting types for `int xmlsqlmap[1]'
xmlsqlmap.h:13: error: previous declaration as `QMap<QString, QString>
xmlsqlmap'
xmlsqlmap.cpp:4: error: ISO C++ forbids declaration of `xmlsqlmap' with no type
xmlsqlmap.cpp:4: error: size of array `xmlsqlmap' has non-integer type
xmlsqlmap.cpp:4: error: redefinition of `int xmlsqlmap[1]'
can anyone tell my why this happens, and how to fix it ?