There are always pros and cons of using macros in your project.The advantage of using a macro is that it reduces the amount of coding you need to do , and the disadvantages of using a macro other than the fact that the size of the executable code is increased its also difficult to debug.
I personally try to stay away from macros but hey , you should always be familiar with things you never know when you might come across them , just like i did at work :(
#define IMPLEMENT_SET_GET_METHOD( type , name ) \
IMPLEMENT_SET_METHOD( type , name ); \
IMPLEMENT_GET_METHOD( type , name );
#define IMPLEMENT_SET_METHOD( type , name ) \
private: type name; \
public: void set_##name( const type& value ) { name = value; }
#define IMPLEMENT_GET_METHOD( type , name ) \
public: const type& get_##name() const { return name; }
class myclass
{
IMPLEMENT_SET_GET_METHOD( int , val)
} ;
void main()
{
myclass obj;
obj.set_val(34);
cout << obj.get_val();
cin.get();
}
I personally try to stay away from macros but hey , you should always be familiar with things you never know when you might come across them , just like i did at work :(
#define IMPLEMENT_SET_GET_METHOD( type , name ) \
IMPLEMENT_SET_METHOD( type , name ); \
IMPLEMENT_GET_METHOD( type , name );
#define IMPLEMENT_SET_METHOD( type , name ) \
private: type name; \
public: void set_##name( const type& value ) { name = value; }
#define IMPLEMENT_GET_METHOD( type , name ) \
public: const type& get_##name() const { return name; }
class myclass
{
IMPLEMENT_SET_GET_METHOD( int , val)
} ;
void main()
{
myclass obj;
obj.set_val(34);
cout << obj.get_val();
cin.get();
}

