melt日記

.NETすらまともに扱えないへたれのページ

ホーム 連絡をする 同期する ( RSS 2.0 ) Login
投稿数  111  : 記事  3  : コメント  8233  : トラックバック  41

ニュース

わんくま同盟

わんくま同盟

C# と VB.NET の質問掲示板

iKnow!


Dictation



書庫

今日初めて知ったんですけど、C# とかで使われてる property って、Microsoft のコンパイラ限定であれば C++ でも使えるんですね。

class Hoge
{
public:
    Hoge() : _value(0) { }
public:
    __declspec(property(get=GetValue, put=SetValue))
        int Value;

int GetValue() { return _value; } void SetValue(int value) { _value = value; } private: int _value; };
void main() { Hoge hoge; hoge.Value = 10; // hoge.SetValue(10); hoge.Value += 10; // hoge.SetValue(hoge.GetValue() + 10); }

__declspec すごΣ(゚Д゚)


他にも、

__declspec(thread) int value;

ってすれば、スレッド毎に value が生成されるみたいです。


__declspec すごΣr(‘Д‘n)


追記:

複数の値を取る property もいけるようです。

class Hoge
{
public:
    Hoge(){ ::memset(_aValue, 0, sizeof(_aValue)); }
public:
    __declspec(property(get=GetValue, put=SetValue))
        int Value[];

int GetValue(int x, int y) { return _aValue[y][x]; } void SetValue(int x, int y, int value) { _aValue[y][x] = value; } private: int _aValue[10][10]; };
void main() { Hoge hoge; hoge.Value[0][1] = 2; // hoge.SetValue(0, 1, 2); hoge.Value[2][3] += 10; // hoge.SetValue(2, 3, hoge.GetValue(2, 3) + 10); }

__declspec すご( ̄□ ̄;)!!

投稿日時 : 2007年3月12日 0:37

コメント

# re: __declspec(property()) 2007/03/12 1:13 CH3COOH
今までに__declspec(dllimport)はも聞いたことありましたけど、property()でもOKだなんて……

__declspec()って何者だΣ(゚Д゚;≡;゚д゚)

# re: __declspec(property()) 2007/03/12 12:20 アキラ
こちらが正しいですね。
int Value[][];


プロパティおもしろいですね~
ぜひ標準C++に加えてほしいです

# re: __declspec(property()) 2007/03/12 12:58 シャノン
C#のインデクサっぽいものも作れそうだな…
あんまりありがたみはないけど。

# re: __declspec(property()) 2007/07/14 23:23 通りすがり
BorlandのC++コンパイラでも使えますよ

# re: 連続性を管理する 2007/08/03 21:59 ホップ・ステップ・εミ(ο_ _)ο ドテッ
re: 連続性を管理する

# QqJslgyijPCIbfTES 2014/08/28 3:12 http://crorkz.com/
IqYZys Thanks - Enjoyed this article, can you make it so I get an update sent in an email every time you make a fresh post?

# TPLlEAgffmRYWGYz 2021/07/03 4:56 https://www.blogger.com/profile/060647091882378654
Wow, awesome weblog structure! How long have you ever been running a blog for? you make running a blog look easy. The total look of your website is excellent, let alone the content!

# Illikebuisse puvqf 2021/07/04 22:42 pharmaceptica
when was hydroxychloroquine first used https://pharmaceptica.com/

# Illikebuisse zwsmt 2021/07/05 4:50 pharmaceptica
methotrexate side effects usmle https://www.pharmaceptica.com/

# re: __declspec(property()) 2021/07/11 1:03 dangers of hydroxychloroquine
chloroquinolone https://chloroquineorigin.com/# what is hydroxychloride

# re: __declspec(property()) 2021/07/26 12:38 dosage for hydroxychloroquine
is chloroquine safe https://chloroquineorigin.com/# is hydroxychloroquine quinine

# re: __declspec(property()) 2021/08/07 16:53 dosage for hydroxychloroquine
premature babies wikipedia https://chloroquineorigin.com/# lupus wikipedia english

# giwjrsbnshts 2021/11/26 14:13 dwedayrjcg
https://hydrochloroquineeth.com/ what does hydroxychloroquine do

# rnflcwmrqjao 2022/05/07 22:05 rqcjvp
hydroxychloroquine sulfate classification https://keys-chloroquinehydro.com/

# ugjgjlsanvtc 2022/05/17 8:10 rpqbgz
hydrchloroquine https://keys-chloroquineclinique.com/

# cost of plaquenil 200 mg 2022/12/27 4:21 MorrisReaks
chloroquine tablets price http://www.hydroxychloroquinex.com/

Post Feedback

タイトル
名前
Url:
コメント