We have macros that create the get and set functions for you. Here's an example of one of them.
Code:// Purpose: // HAS_A is used for quickly creating a private class member variable with corresponding // public Get and Set functions. // // Usage: // HAS_A( type , name ) // Example: HAS_A(int, Count) // The above example expands to the following code: // // private: // int m_Count; // public: // const int & GetCount () const { return m_Count; } // void SetCount(const int & inValue) { m_Count = (( int &)inValue); } // // Notes: // 1) HAS_A can change the scope of members and methods declared after it. In the following // example the declaration of X is public, not private. // // private: // HAS_A(int, Count) // int X; // // For this reason HAS_A is usually used at the end of a class. // // 2) HAS_A is case sensitive. The following example creates Getcount and Setcount methods, // not GetCount and SetCount. // // HAS_A(int, count) #define HAS_A( inType, inName )\ private: \ inType m_ ## inName; \ public: \ virtual const inType & inName () const { return m_ ## inName; } \ virtual void inName(const inType & inValue) { m_ ## inName = (( inType &)inValue); }




Reply With Quote
