-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simple inheritance with
base: ParentClass,
- Loading branch information
Showing
4 changed files
with
66 additions
and
8 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
pub const vec2_t = extern struct { | ||
x: f32, | ||
y: f32, | ||
}; | ||
|
||
pub const shape_t = extern struct { | ||
vtable: *const anyopaque, // manually added | ||
|
||
aabb: vec2_t, | ||
|
||
extern fn _ZNK7shape_t4areaEv(self: *const shape_t) f32; | ||
pub const area = _ZNK7shape_t4areaEv; | ||
}; | ||
|
||
pub const circle_t = extern struct { | ||
base0: shape_t, | ||
|
||
radius: f32, | ||
|
||
extern fn _ZNK8circle_t4areaEv(self: *const circle_t) f32; | ||
pub const area = _ZNK8circle_t4areaEv; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
struct vec2_t { | ||
float x; | ||
float y; | ||
}; | ||
|
||
class shape_t { | ||
public: | ||
vec2_t aabb; | ||
virtual float area() const = 0; | ||
}; | ||
|
||
class circle_t: public shape_t { | ||
public: | ||
virtual float area() const = 0; | ||
|
||
private: | ||
float radius; | ||
}; |