HP aC++/HP C A.06.20 Programmer's Guide
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.
int S:: f( ) { return 1;}
main() {
return 1; }
Using :: in Class Definitions
In HP C++, you can declare members of classes inside the class using the following
incorrect syntax:
class_name::member_name
In HP aC++, this incorrect syntax is considered an error. You must remove the
class_name:: specification from the member definition.
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 you cannot qualify
members of class X in the class definition.
class X{
int X::f();
// int f(); // This will fix the problem and
// run successfully on both compilers.
280 Migrating from HP C++ (cfront) to HP aC++