HP aC++/HP C A.06.25 Programmer's Guide
The following code currently compiles without errors with HP C++ and HP aC++. In
the future, HP aC++, will generate an error.
int main(int argc) {
for (int i = 1; i < argc; ++i) {
}
for (i = 0; i < argc; ++i) {
}
}
Correct the code as follows:
int main(int argc) {
int i;
for (i = 1; i < argc; ++i) {
}
for (i = 0; i < argc; ++i) {
}
}
This code complies with ANSI/ISO C++ International Standard syntax and compiles
with both compilers.
struct as Template Type Parameter is Permitted
In HP C++, an error is generated when a struct is used as a template type parameter.
In HP aC++, when a struct is used as a template type parameter, it is correctly
compiled, in accordance with draft standard syntax. This is a new feature.
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:
Migration Considerations Related to Standardization 279