1 | #import <objc/NSObject.h> |
2 | |
3 | class MyCPPClass { |
4 | public: |
5 | MyCPPClass(float f) : f(f) {} |
6 | |
7 | float setF(float f) { |
8 | float oldf = this->f; |
9 | this->f = f; |
10 | return oldf; |
11 | } |
12 | |
13 | float getF() { |
14 | return f; |
15 | } |
16 | private: |
17 | float f; |
18 | }; |
19 | |
20 | typedef MyCPPClass MyClass; |
21 | |
22 | @interface MyObjCClass : NSObject { |
23 | int x; |
24 | } |
25 | - (id)init; |
26 | - (int)read; |
27 | @end |
28 | |
29 | @implementation MyObjCClass { |
30 | int y; |
31 | } |
32 | - (id)init { |
33 | if (self = [super init]) { |
34 | self->x = 12; |
35 | self->y = 24; |
36 | } |
37 | return self; |
38 | } |
39 | - (int)read { |
40 | return self->x + self->y; |
41 | } |
42 | @end |
43 | |
44 | int main (int argc, const char * argv[]) |
45 | { |
46 | MyClass my_cpp(3.1415); |
47 | return 0; // break here |
48 | } |
49 | |
50 | |