Here is my header code:
#ifndef CLANDTYPES_H
#define CLANDTYPES_H
class CLandTypes
{
public:
CLandTypes();
~CLandTypes();
private:
class Pimple;
static Pimple * d;
};
#endif // CLANDTYPES_H
because it should be a static class I tryed to code in my cpp file:
#include "clandtypes.h"
CLandTypes::Pimple * CLandTypes::d = new CLandTypes::Pimple();
...
But something is wrong!
---------- EDIT ----------
here is my extended c++ code:
#include "clandtypes.h"
#include "qvector.h"
#include "qpair.h"
CLandTypes::Pimple * CLandTypes::d = new CLandTypes::Pimple();
class CLandTypes::Pimple
{
public:
Pimple();
~Pimple();
QVector > LandTypes;
};
CLandTypes::Pimple::Pimple()
: LandTypes(NULL)
{
LandTypes.push_back(qMakePair((unsigned int) 0, (QString)"undefined"));
LandTypes.push_back(qMakePair((unsigned int) 1, (QString)"rocky"));
}
CLandTypes::Pimple::~Pimple(){}
CLandTypes::CLandTypes()
{
if (!d)
{
d = new Pimple();
if (!d)
{
throw std::bad_alloc();
}
}
}
CLandTypes::~CLandTypes()
{
if(d)
{
delete d;
d = NULL;
}
}
my two errors are:
invalid use of incomplete type 'struct CLandTypes::Pimple'
forward declaration of 'struct CLandTypes::Pimple'