-
-
Save kou-yeung/e24ff374ac46a22c3093027c923e17aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
{ | |
public: | |
int val; | |
}; | |
// メソッドFunc「渡された引数を変更しませんよ!」って const 付けます | |
void Func(const Foo& foo) | |
{ | |
foo.val = 10; // コンパイルエラー | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// クラスFoo「メンバーを見るのはいいが手を出さないでね」って プロパティに private set にしました | |
class Foo { | |
public int val{ get; private set; } | |
} | |
class prop | |
{ | |
static void Func(Foo foo) | |
{ | |
foo.val = 10; // コンパイルエラー | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment