blob: 570ae1761c2f6e20a25dac981047df2b034a9e61 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
namespace;
include rt;
// struct methods declare a return type and typed parameters, like functions do
struct Str {
int len;
static int size(int s) { return s * 2; }
int plus(int k) { return this.len + k; }
static fn none() { return 5; }
}
int main() {
Str a;
a.len = 9;
rt.put_n(Str.size(7)); rt.put_c(32);
rt.put_n(Str.none()); rt.put_c(32);
rt.put_n(a.plus(4));
rt.put_c(10);
return 0;
}
|