C++ pimpl idiom and static method and fields -


I would like to understand how to use a static field in the presence of PIMPL phrases in a method. Consider the following code.

MyClass.h file:

  #ifndef MYCLASS # MacCalls class MyClass {public: zero method (); Static zero static_moth (); Private: type field; Fixed type * static_field; } MyClass :: method () {/ * OK method definition * / field = # New Type (); / * OK field creation * Zero MyClass :: static_method () {/ * Not working declarion * / static_field = new Type (); I have these two errors:  
  1. Members can not declare static_method to work on a static task / Li>
  2. Static_field was not declared in this area

    I am not very familiar with the Pimple idiom.

    So my question is how do I respect the stable methods and fields to respect the PIMPL idiom and compile it successfully?

    What am I doing in this code?

    How do I change my code?

    • Show us the actual code that you have verified verifies the error
    • Do not put in front of the static function definition in the .cpp file
    • You do not have static_field - You have two fields < / Ul>

Comments