Skip to content

Instantly share code, notes, and snippets.

@MhdSyrwan
Created June 1, 2012 23:49
Show Gist options
  • Save MhdSyrwan/2855837 to your computer and use it in GitHub Desktop.
Save MhdSyrwan/2855837 to your computer and use it in GitHub Desktop.
C++ Properties Test
#include <iostream>
using namespace std;
#define PROPERTY_AUTO(name,type,Name) type name; type get ## Name () { return name; } void set ## Name ( type value ) { this-> name ; }
#define READONLY(name,type,Name) type name; type get ## Name () { return name; }
#define PROPERTY(name,type,Name,block) type name; type get ## Name () { return name; } void set ## Name (type value) { block }
class Person {
public:
PROPERTY(firstName,string,FirstName,
{
cout << "in property block \n";
this->firstName = value;
})
Person() {
firstName = "no name";
}
};
int main(){
Person person;
person.setFirstName("MhdSyrwan");
cout << person.getFirstName();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment