Error: File “DDB4270.C”, Line 7

A pointer to member cannot be created from a parenthesized or unqualified name.

To successfully compile the code, remove the parentheses from the last line.

Example:

class A { public:

int i;

static int (A::*p);

};

int (A::*(A::p)) = &A::i;

&qualified-id Required in Static Member Initialization List

In HP C++, you can use an unqualified function name in a static member initialization list. In HP aC++, an unqualified function name in a static member initialization list causes an error and the program does not compile. Use the unary operator & followed by a qualified-id in the member initialization list. The resulting code compiles correctly with HP C++ and HP aC++.

Example:

class A { public:

int i; int j();

static int (A::*p)(); };

int (A::*(A::p))() = j;

Compiling this code with HP aC++ generates the following error:

Error: File “DDB4270A.C”, Line 7

Cannot initialize ‘int (A::*)()’ with ‘int (*)()’.

To successfully compile with HP C++ and HP aC++, change the initialization list in line 7 to &A::j;

class A { public:

int i; int j();

static int (A::*p)(); };

int (A::*(A::p))() = &A::j;

Non-constant Reference Initialization

In HP C++, if you do not initialize a non-constant reference with an lvalue, an anachronistic warning is issued and compilation continues. In HP aC++, an error is issued if you do not use an lvalue for a non-constant reference initialization. Use an lvalue for the reference initialization, or define the reference as a const type.

Example:

void f(int &); int main () {

f(3); return 0;

}

Compiling this code with HP C++ generates the following warning:

CC:“DDB04313A.C”, line 4: warning: temporary used for non-const int & argument; no changes will be propagated to actual argument (anachronism) (283)

Compiling the above code with HP aC++ generates the following error:

Future Error: File “DDB04313A.C”, Line 4

The initializer for a non-constant reference must be an lvalue.

Try changing ‘int &’ to ‘const int &’.

218 Migrating from HP C++ (cfront) to HP aC++

Page 218
Image 218
HP C/aC++ for PA-RISC Software manual Qualified-id Required in Static Member Initialization List