Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ------------ this is the struct, notice it has a Color struct member that has RGB members
- const Color = @import("color.zig").Color;
- pub const Point = struct {
- x: f32,
- y: f32,
- color:*Color,
- pub fn init(x:f32,y:f32, c: *Color) Point {
- return Point {
- .x=x,
- .y=y,
- .color=c,
- };
- }
- };
- // ------------ If I create a point like this, my concern is that this is the equivalent of handing out a local pointers.
- // ultimately I would prefer the Color member be a value, but it seems to me that I cannot do that and
- // it also seems to me that I MUST use a pointer, which implies that I MUST use explicit allocation.
- // Is this correct, or am I missing something?
- //
- var p = Point.init(3,4,&Color.init(0,0,0));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement