Re: Sanity check: public/private
Carlos Moreno wrote:
1) private is only used as class-member access specifier
According to the holly standard, the memory layout
for variables separated by different access specifiers
is implementation issue. Therefore if you change
private to public, the member layout maybe different.
2) private is also used for inheritance.
For following example,
struct B
{
int t;
};
struct D1 : private B // private inheritance (hold-a)
{
D1(){ t = 0; }
};
struct D2 : public D1
{
D2(){ t = 0; } // error, B::t is not accessible.
};
So, again private and public make difference here.
Someone could use above behavior to implement
compile-time checking/assertion, maybe.
(I believe the answer NO is valid for both cases, but I'm
mostly interested in case (1), so if the answer is different,
please specify the reasoning for both cases).
Actually I do not known any compilers really treat
private and public member differently, because
access specifiers are purely logical constructs.
But I do not have a good reason to do such a
replacement. :-)
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]