Hiding class pointers -- was it a good idea?
Walter Bright
newshound1 at digitalmars.com
Thu Aug 16 01:49:56 PDT 2007
James Dennett wrote:
> For one, rather restricted, notion of OOP. There are many,
> many views of what constitutes OOP in the PL community.
The definition I use is a common one, OOP design consists of three
characteristics:
1) inheritance
2) polymorphism
3) encapsulation
>> In C++, an OOP class can be used/misused by the user as a value type or
>> a reference type, all out of the purview of the class designer. The
>> class designer must control this, not the class user.
>
> It's normal in C++ to make "entity" classes (those that
> you're calling reference types) noncopyable. It's also
> normal to make base classes abstract. Thus idioms easily
> prevent the basic misuses.
C++ is loaded with idioms and conventions to try and head off major
problems. I'd rather snip off such problems at the source - for one
reason, it will dramatically reduce the learning curve of the language.
For another, the more guarantees the language can offer, the lesser a
burden it is on the code auditor, and the more likely the code is to be
correct.
More information about the Digitalmars-d
mailing list