C/C++ Programmer's Guide (G06.25+)

C and C++ Extensions
HP C/C++ Programmer’s Guide for NonStop Systems429301-008
2-6
Declarations
Only members that are introduced by the class are exported or imported; methods
inherited by the class are not exported or imported.
Do not export a class definition in more than one compilation unit or load unit, and
do not mix explicit export$/import$ usage with default class definitions. That is,
linking or loading errors, or erroneous run-time type checking can occur if either
one of the following two paradigms is not followed:
°
Exactly one compilation unit (and one load unit) explicitly exports the class
(wholly or selectively), and all others explicitly import it.
°
Every compilation unit defining the class uses a default definition (neither
export$ nor import$).
Examples of Export Attribute (Native C++ Only)
// export everything from a class
class export$ C1 {
public:
int I; // class data, not exported
int foo (void) {returnI ;} // Exported member function
static int J; // Exported static data member
};
int C1::J = 1; // Definition for exported static data member
// import everything from a class
class import$ C2 {
public :
int I; // Class data, not imported
int foo (void) {return I;} // Imported member function,
// definition ignored
static int J; //Imported static data member
};
int C2::J = 1; // Error: definition for imported static data member
//selective exporting/importing
class C3a {
public :
int I;
int foo (void) {return I;} // Member function -
// neither exported nor imported
export$ static int J; // Exported static data member
};
int C3a::J = 1; //Definition for exported static data member
class C3b {
public :
int I;
int foo (void) {return I;} // Member function -
// neither exported nor imported
import$ static int J; // Imported static data member