Created
April 16, 2011 21:07
-
-
Save dabroz/923500 to your computer and use it in GitHub Desktop.
This file contains 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 <stdio.h> | |
#include <math.h> | |
#include <stddef.h> | |
class Square | |
{ | |
private: | |
float _edge; | |
public: | |
@property float edge | |
{ | |
get | |
{ | |
return _edge; | |
} | |
set | |
{ | |
_edge = value; | |
} | |
} | |
@property float area | |
{ | |
get | |
{ | |
return _edge * _edge; | |
} | |
set | |
{ | |
_edge = sqrtf(value); | |
} | |
} | |
}; | |
void print(float edge, float area) | |
{ | |
printf("edge = %f, area = %f\n", edge, area); | |
} | |
int main() | |
{ | |
Square s; | |
s.area = 25; | |
print(s.edge, s.area); | |
s.edge = 3; | |
print(s.edge, s.area); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment