HP aC++/HP C Programmer's Guide (B3901-90036; A.06.26; September 2011)
Example:
Compiling and linking the following code on HP C++ gives no warning nor error.
Compiling the code on HP aC++ gives neither a warning nor an error. Linking the
resulting object file generates a linker (ld) error that states that there are unsatisfied
symbols.
class A {
public:
static int staticmember;
};
// int A::staticmember=0; // This would fix the problem.
int main ()
{
A::staticmember=1;
}
Declaring friend Classes
In HP C++, you can declare friend classes without the class keyword. In HP aC++,
declaring friend classes without the class keyword generates an error. To change
this, add the class keyword to all friend class declarations.
Example:
Compiling the following code on HP C++ does not generate a warning or an error.
Compiling the code on HP aC++ generates an error stating that the friend declaration
for B is not in the right form for either a function or a class.
class foo{
public:
friend bar; // Need to say: friend class B
};
int main (){
return 1;
}
Incorrect Syntax for Calls to operator new
In HP C++, you can use incorrect syntax to call operator new. In HP aC++, an error
is generated when incorrect syntax for operator new is used. To change this, add
parentheses around the use of operator new. This code compiles correctly with both
HP C++ and HP aC++.
Example:
Compiling the following code on HP C++ does not generate a warning or an error.
Compiling the code on HP aC++ generates errors stating operator expected instead
of new and undeclared variable operator S.
struct S {int f();};
int g() { return new S->f();}
// int g() { return (new S)->f();} // This will fix the problem.
268 Migrating from HP C++ (cfront) to HP aC++