Classes: Difference between revisions

Content added Content deleted
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>
public class Rectangle{
struct Rectangle{
public double width;
double width;
public double height;
double height;
};
public Rectangle(double width, double height){
Rectangle new(double width,double height){
this.width = width;
Rectangle self;
this.height = height;
self.width = width;
}
self.height = height;
public double area(){
return this.width*this.height;
return self;
}
}
public double perimeter(){
double area(Rectangle self){
return (this.width+this.height)*2.0;
return self.width*self.height;
}
}
double perimeter(Rectangle self){
return (self.width+self.height)*2.0;
}
}
</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.