Besides the normal explenation of being visible or not to derived classes, is their any other difference?
If you make it more visible, is it taking more or less memory, does it slow thing down or...?
Besides the normal explenation of being visible or not to derived classes, is their any other difference?
If you make it more visible, is it taking more or less memory, does it slow thing down or...?
From
n3225
, 9.2 [class.mem] note 15This means that given the following declaration:
Only the following assertions are enforced by the standard:
@Nawaz's citation can be interpreted as giving 4 blocks that can be freely intermixed, but this is not the case. The declaration of
Foo
is perfectly equivalent to:Indeed the compiler completely ignores (for this purpose) whether a specifier appeared once or multiple times, and specifying it each time is spurious and at best slows the compilation down because of the extra parsing. For a human reader, it might be clearer... but this is highly subjective.
Apart from the accessibility of members outside or to the derived classes, access specifiers might affect the object layout.
Quoting from my other answer:
Usually, memory address for data members increases in the order they're defined in the class . But this order may be disrupted at any place where the access-specifiers (
private
,protected
,public
) are encountered. This has been discussed in great detail in Inside the C++ Object Model by Lippman.An excerpt from C/C++ Users Journal,
Interesting, isn't it?