Mögliche Duplizieren statisches Element Array initialisieren:
Where and why do I have to put the “template” and “typename” keywords?Wie in der Klasse mit Vorlage
#include <iostream>
using namespace std;
template <class T>
class Test
{
union obj
{
union obj* next;
int num;
};
static const int SZ=3;
static obj* volatile list[SZ];
};
template <class T>
Test<T>::obj* volatile
Test<T>::list[SZ]=
{
0, 0, 0
};
int main()
{
return 0;
}
mit g ++, die Fehler, die ich bekommen ist:
18|error: expected constructor, destructor, or type conversion before '*' token
fügt 'typename' vor 'Test :: obj * 'hilft? –
Funktioniert es, wenn Sie diese Union außerhalb der Klasse deklarieren? – rutgersmike
Beide sind in Ordnung, aber ich kenne nur Letzteres. – prehistoricpenguin