Seite 1 von 1
(gelöst)[C++]2D-Array automatischer Größe geht nicht
Verfasst: 26.01.2010, 18:11
von Krishty
Hi,
Ist es normal, dass dieser Code nicht funktioniert?
Mit
int Test[][3] geht es, aber ich möchte, dass der Compiler die Größe automatisch bestimmt … mir ist gerade unklar, warum er das nicht hinkriegt. (VCpp 2010)
Gruß, Ky
Re: [C++]2D-Array automatischer Größe geht nicht
Verfasst: 26.01.2010, 18:44
von Arne
Mir ist diese Problem auch bekannt. Eine einleuchtende Erklärung ist mir allerdings auch noch nicht untergekommen.
Ich kann dir als nicht helfen - nur den Frust mit dir teilen ;)
Gruß, Arne
Re: [C++]2D-Array automatischer Größe geht nicht
Verfasst: 26.01.2010, 19:34
von Aramis
'Problem' ist wohl das falsche Wort ... :-)
C++-Standard hat geschrieben:
D1 [ constant-expression opt ]
When several “array of” specifications are adjacent, a multidimensional array is created; the constant expressions that
specify the bounds of the arrays can be omitted only for the first member of the sequence. [ Note: this elision is useful
for function parameters of array types, and when the array is external and the definition, which allocates storage, is
given elsewhere. —end note ] The first constant-expression can also be omitted when the declarator is followed by an
initializer (8.5). In this case the bound is calculated from the number of initial elements (say, N) supplied (8.5.1), and
the type of the identifier of D is “array of N T.”
Re: [C++]2D-Array automatischer Größe geht nicht
Verfasst: 26.01.2010, 20:32
von Krishty
Aramis hat geschrieben:'Problem' ist wohl das falsche Wort ... :-)
Nagut, nennen wir es
aus bestimmten Blickwinkeln inkonsistent. Der Auszug hat es aber nun geklärt … schade drum, aber traurige Gewissheit ist besser als garkeine … danke dafür.