Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP C++ Programmer's Guide: HP 9000 Series Workstations and Servers > Chapter 5 Inter-Language Communication

Data Compatibility between C and C++

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

Since C++ is a superset of C, many of the data types are identical. Both languages have the identical primitive types char, short, int, long, float, and double. ANSI C and C++ also support a long double type (and include a language extension for a long long type for versions 10.22 and later.)

Pointers, structs, and unions that can be declared in C are also compatible. Arrays composed of any of the above types are compatible.

C++ classes are generally incompatible with C structs. The following features of the C++ class facility may cause the compiler to generate extra code, extra fields, or data tables:

  • multiple visibility of members (that is, having both private and public data members in a class)

  • inheritance, either single or multiple

  • virtual functions

It is the use of these features, as opposed to whether the class keyword is used rather than struct, that introduces incompatibilities with C structs.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.