オブジェクト指向の概念を教えれ
■ このスレッドは過去ログ倉庫に格納されています
0112101
NGNGhttp://www.parashift.com/c++-faq-lite/classes-and-objects.html#[7.5]
In C, encapsulation was accomplished by making things static
in a compilation unit or module. This prevented another module
from accessing the static stuff. (By the way, that use is now
deprecated: don't do that in C++.)
Unfortunately this approach doesn't support multiple instances
of the data, since there is no direct support for making multiple
instances of a module's static data. If multiple instances were
needed in C, programmers typically used a struct. But unfortunately
C structs don't support encapsulation. This exacerbates the tradeoff
between safety (information hiding) and usability (multiple instances).
これだと一応カプセル化にも重点を置いてるけど、JavaにしろPythonにしろ、
デフォルトのアクセス制限を緩くしている。
カプセル化が重要じゃないとは言わないが、少なくとも真っ先に説明することじゃ
ないと思うんだけどなあ。
■ このスレッドは過去ログ倉庫に格納されています