Ein seltsames CPP-Codebeispiel (vielleicht?) über Typedef aus einem Buch mit dem Titel „The Design and Evolution of C++“
Posted: 16 Jan 2025, 09:04
Ich kann statisches Q(P) im folgenden Codebeispiel nicht verstehen:
Meiner Meinung nach bedeutet „Q ist in diesem Bereich kein Typ mehr“ bedeutet, dass Q jetzt ein Funktionsname ist. Warum kann er also wie statisches Q(P) verwendet werden?
Dieses Codebeispiel scheint nicht gültig zu sein (betroffen von der Grammatik).
Code: Select all
typedef int P();
typedef int Q();
class X {
static P(Q); // define Q to be a P.
// equivalent to `static int Q()`
// the parentheses around Q are redundant
// Q is no longer a type in this scope
static Q(P); // define Q to be a function
// taking an argument of type P
// and returning an int.
// equivalent to `static int Q(int())`
};
Dieses Codebeispiel scheint nicht gültig zu sein (betroffen von der Grammatik).