Navigation Menu

Skip to content

Commit

Permalink
doc coding-style: add about assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Mar 15, 2012
1 parent e1c194f commit 2793a5a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions doc/source/developer/coding_style.rst
Expand Up @@ -293,3 +293,34 @@ TODO: ちゃんと考える。
this.age_ = object.age_;
}
}

クラスの代入
------------

基本的に定義したクラスの代入を禁止する。

よい例:

class MyClass
{
private:
MyClass &operator=(const MyClass &);
}

悪い例(代入を禁止していない):

class MyClass
{
}

悪い例(代入を使っている):

class MyClass
{
unsigned int age_;
MyClass &operator=(const MyClass &object)
{
age_ = object.age_;
return *this;
}
}

0 comments on commit 2793a5a

Please sign in to comment.