ユーザ用ツール

サイト用ツール


サイドバー

C++/CLI

CLR

実用編

その他

cli:indexed_property

以前のリビジョンの文書です


indexed property

indexed propertyはC++のoperator[]のようなものです。

ref class C {
    array<double>^ d;
public:
    C() {
        d = gcnew array<double>(10);
    }
    property double default[int]
    {
        double get(int i) { return d[i]; }
        void   set(int i, double t) { d[i] = t; }
    }
};
int main()
{
    C c;
    c[5] = 5;
    double d = c[5];
}

propertyにgetメソッドを定義しなければ、書き込みオンリーにすることもできます。




/var/www/html/virtual/cppcli/data/attic/cli/indexed_property.1233382102.txt.gz · 最終更新: 2013/12/23 09:07 (外部編集)