Skip to content

Instantly share code, notes, and snippets.

@kou-yeung
Last active June 19, 2016 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kou-yeung/e24ff374ac46a22c3093027c923e17aa to your computer and use it in GitHub Desktop.
Save kou-yeung/e24ff374ac46a22c3093027c923e17aa to your computer and use it in GitHub Desktop.
class Foo
{
public:
int val;
};
// メソッドFunc「渡された引数を変更しませんよ!」って const 付けます
void Func(const Foo& foo)
{
foo.val = 10; // コンパイルエラー
}
// クラス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