Classes: Difference between revisions
Content added Content deleted
(→{{header|GLSL}}: oops) |
|||
Line 1,529: | Line 1,529: | ||
There are no classes in GLSL, but they can be simulated using structs: |
There are no classes in GLSL, but they can be simulated using structs: |
||
<lang> |
<lang> |
||
struct Rectangle{ |
|||
double width; |
|||
double height; |
|||
}; |
|||
Rectangle new(double width,double height){ |
|||
⚫ | |||
Rectangle self; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
public double area(){ |
|||
return self; |
|||
} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
double area(Rectangle self){ |
|||
⚫ | |||
return self.width*self.height; |
|||
} |
|||
} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
} |
} |
||
</lang> |
</lang> |
||
=={{header|Go}}== |
=={{header|Go}}== |
||
The task describes several concepts concerning class methods before giving some task requirements. The following code satisfies the task requirements. The concepts described however, are more involved. A discussion of these concepts follows. |
The task describes several concepts concerning class methods before giving some task requirements. The following code satisfies the task requirements. The concepts described however, are more involved. A discussion of these concepts follows. |