Created
June 1, 2012 23:49
-
-
Save MhdSyrwan/2855837 to your computer and use it in GitHub Desktop.
C++ Properties Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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