Navigation Menu

Skip to content

Commit

Permalink
doc coding-style: add about const
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Mar 15, 2012
1 parent 53d12f7 commit c8d570b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions doc/source/developer/coding_style.rst
Expand Up @@ -354,3 +354,32 @@ voidを省略
return age_;
};
}

入力用引数にはconstを付ける
^^^^^^^^^^^^^^^^^^^^^^^^^^

入力のみに用いる引数には ``const`` を付ける。

よい例:

class Table
{
void insert(unsigned int id, const char *column_name, const char *value)
{
Record *record = records[i];
Column *column = columns[column_name];
column.set_value(value);
}
}
悪い例(入力のみに用いているのに ``const`` が付いていない):

class Table
{
void insert(unsigned int id, char *column_name, char *value)
{
Record *record = records[i];
Column *column = columns[column_name];
column.set_value(value);
}
}

0 comments on commit c8d570b

Please sign in to comment.