diff options
author | chai <chaifix@163.com> | 2021-10-31 14:27:26 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-31 14:27:26 +0800 |
commit | 601442f94fc0dcfdc5a117c5f87d90b156d53045 (patch) | |
tree | b006bcd6a28a965a900c64f4716007fcb45eee98 /ThirdParty/StaticConstructor/StaticConstructorSample/MyClass.h | |
parent | 26f05c6e3dcac9995345fb5a2b031be7e3ea79e9 (diff) |
+static initiator
Diffstat (limited to 'ThirdParty/StaticConstructor/StaticConstructorSample/MyClass.h')
-rw-r--r-- | ThirdParty/StaticConstructor/StaticConstructorSample/MyClass.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/ThirdParty/StaticConstructor/StaticConstructorSample/MyClass.h b/ThirdParty/StaticConstructor/StaticConstructorSample/MyClass.h new file mode 100644 index 0000000..5f86f22 --- /dev/null +++ b/ThirdParty/StaticConstructor/StaticConstructorSample/MyClass.h @@ -0,0 +1,36 @@ +// MyClass.h +// +#include <string> +#include <StaticConstructor.h> + + +class MyClass +{ +protected: + // Declaration of protected static data members: + // Cannot be initialized here (C++ language limitation) + static void* mpStaticMemory; + static const double mPI; + static std::string mStaticStr; + +public: + // Static function members to get the static data members (to unify the Tests): + static const double& PI() { return mPI; }; + static std::string& StaticStr() { return mStaticStr; }; + +public: + // Default Constructor: + MyClass(); + + // Destructor: + virtual ~MyClass(); + + // Static Constructor: + // (Should be called by INVOKE_STATIC_CONSTRUCTOR macro in the CPP file) + STATIC_CONSTRUCTOR(); + + // Static Destructor: + // (Should be called by INVOKE_STATIC_CONSTRUCTOR macro in the CPP file) + STATIC_DESTRUCTOR(); +}; + |