Classes: Difference between revisions

Line 1,529:
There are no classes in GLSL, but they can be simulated using structs:
<lang>
public classstruct Rectangle{
public double width;
public double height;
};
Rectangle public Rectanglenew(double width, double height){
this.width = width;
Rectangle self;
this.height = height;
thisself.width = width;
}
thisself.height = height;
public double area(){
return this.width*this.heightself;
}
}
}
public double perimeter(){
double area(Rectangle self){
return (this.width+this.height)*2.0;
return self.width*self.height;
}
}
}
public double perimeter(Rectangle self){
return (thisself.width+thisself.height)*2.0;
}
</lang>
 
=={{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.
Anonymous user