HP aC++/HP C Programmer's Guide (B3901-90036; A.06.26; September 2011)
Example:
template class A {
public:
struct T a;
};
struct B {};
A b;
The following error appears when you compile this code with HP C++:
CC: "DDB4325.C", line 3: error: T of type any redeclared as
struct (1479)
This code compiles without error with HP aC++.
Base Template Class Reference Syntax Change
In HP C++, you can reference a member of a base template class without qualifying the
member. In HP aC++, when you reference a member of a base template class, you must
qualify the member by adding this->.
Adding this-> defers name resolution until instantiation. This allows the compiler to
find members in template base classes. However, it prevents the compiler from finding
names declared in enclosing scopes.
Example:
template class BaseT {
public:
T t;
int i;
};
template class DerivedT : public BaseT {
public:
void foo1 () { t = 1; i = 1; } // warning 721
// t and i could be global.
void foo2 () { this->t = 2; this->i = 2; } // Correct syntax, no warning.
};
DerivedT d; // Here is the point of instantiation.
Tokens after #endif
In HP C++, any character that follows the #endif preprocessor statement causes a
warning and is ignored. In HP aC++, characters following the #endif preprocessor
statement cause an error and the program does not compile. To change this, remove all
characters following all #endif preprocessor statements or put the token in comments.
Example:
Compiling the following code with HP C++ causes a warning. Compiling with HP aC++
generates an error.
int main(){
#ifdef FLAG
int i;
i=1;
266 Migrating from HP C++ (cfront) to HP aC++