mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-11-27 04:44:08 +03:00
Finished basic OOP
This commit is contained in:
parent
a6c3a64a4c
commit
35aa1410e2
@ -251,6 +251,25 @@ interface InterfaceDemo { // Can be used as a mixin
|
|||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Since method overloading isn't possible, you can use named constructors
|
||||||
|
// to get the same functionality.
|
||||||
|
|
||||||
|
public class Calculator : GLib.Object {
|
||||||
|
|
||||||
|
public Calculator() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Calculator.with_name(string name) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Calculator.model(string model_id, string name = "") {
|
||||||
|
this.with_name(@"$model_id $name"); // Chained constructors with "this"
|
||||||
|
}
|
||||||
|
~Calculator() { } // Only needed if you're using manual memory management
|
||||||
|
}
|
||||||
|
|
||||||
|
var calc1 = new Calculator.with_name("Temp");
|
||||||
|
var calc2 = new Calculator.model("TI-84");
|
||||||
|
|
||||||
enum HouseSize {
|
enum HouseSize {
|
||||||
SMALL,
|
SMALL,
|
||||||
|
Loading…
Reference in New Issue
Block a user