ユーザー定義のプロパティ
新たにプロパティを定義することもできる。
import std.c.stdio; class Hoge{ this(){ m_hoge = 1; } int hoge(){ return m_hoge; } int hoge(int value){ return m_hoge = value; } private: int m_hoge; } void main(){ Hoge hoge = new Hoge(); printf("hoge is %d\n", hoge.hoge); hoge.hoge = 5; printf("hoge is %d\n", hoge.hoge); }
実行。
C:\d>uprop hoge is 1 hoge is 5
Rubyだ。