Boost logo

Boost :

Subject: Re: [boost] Pimpl Again?
From: Vladimir Batov (Vladimir.Batov_at_[hidden])
Date: 2016-05-31 19:42:00


On 2016-06-01 05:03, Emil Dotchevski wrote:
> ...
> The problem from language design point of view is that in C++ the "dot
> syntax" can only be used with member functions, but member functions
> have
> access to the private data, which means that they must participate in
> the
> type definitions (encapsulation), which means they can't be called
> without
> the type being complete. The C++ solution to this problem is to use
> only
> abstract types with no data members in header files, but that has
> virtual
> function call overhead compared to the C-style approach.
>
> It would have been useful for C++ to allow the declaration of
> non-friend
> "member" functions outside of the type definition. This would require
> no
> change in syntax.

Interesting... and liberating... and dangerous... :-) Aren't you
suggesting to actually officially support encapsulation violation? Say,
by your book I can write a new free-standing "member" function to your
class and cause quite a bit of mischief in there.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk