I would like to better understand how to use static field an method in the presence of PIMPL idiom. Consider the following code.
MyClass.h file:
#ifndef MYCLASS
#define MYCLASS
class MyClass{
public:
void method();
static void static_method();
private:
Type field;
static Type *static_field;
}
#endif
MyClass.cpp file:
#include MyClass.h
void MyClass::method(){
/*OK method definition*/
field = new Type(); /*OK field construction*/
}
void MyClass::static_method(){
/*NOT WORKING method declaraion */
static_field = new Type(); /*not working */
}
I have these 2 errors:
I'm not very familiar with pimpl idiom.
So my question is how I achieve static methods and fields declarations to respect the PIMPL idiom and compile it successfully?
What am I doing wrong in this code?
How have I to change my code?
static_field
- you have two field