Eliminating private members from header files

M

Medvedev

When i make a dynamic link library is it allowed to eliminate the
private data members of the classes from the header file which i offer
to the client ?!!
 
J

James Kanze

When i make a dynamic link library is it allowed to eliminate the
private data members of the classes from the header file which i offer
to the client ?!!

No. When the client links includes your object code in his
program, be it by dynamic linking or static, the class
definition his code sees must be identical with that you used to
compile your code. The only thing you can possibly remove from
it is comments. (The identity is required at the token level.)
In practice, you can usually get away with a few things---private
static data members, for example---but as far as the language is
concerned, as soon as the token sequence is not identical in all
translation units, you have undefined behavior.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,233
Latest member
AlyssaCrai

Latest Threads

Top