[Effective-cpp] Item 34: Understand How to Combine C++ and C in the Same Program.

Kloss, Burkhard Burkhard.Kloss at kbcfp.com
Fri Jun 6 06:39:07 EDT 2003


I'd say the rule is implied - after all, a favourite interview question is "what is the difference between a struct and a class?" A: nothing, apart from the default access specifier.  Hence you'd expect classes to be laid out the same way as structs, since they are the same thing.

Of course, there's nothing stopping you adding virtual functions to a struct, either, in which case all bets w.r.t. C compatibility are off anyway.

-----Original Message-----
From: David Sykes [mailto:davids at revolution.co.uk]
Sent: 06 June 2003 11:17
To: 'effective-cpp at accu.org'
Subject: RE: [Effective-cpp] Item 34: Understand How to Combine C++ and
C in the Same Program.


I have done the same, passing c++objects as structs, and it worked a treat. 
I don't know if there is a rule that objects should be represented in the 
same way as structs, though, and if there is not then presumably there is 
the potential for a mismatch.




More information about the Effective-cpp mailing list