そのため、可変サイズの新しい配列を作成できないという問題があります(変数はとして宣言されていますconst int
)
これがコードです
#include <iostream>
#include <string>
int newArraySize;
int main ()
{
std::cin >> newArraySize;
int const fin = newArraySize;
int deduped[fin]; // Here is the error
}
私が得ているエラーは
エラー:式には定数値が必要です
定数としてキャストしようとしましたが、それでも運がありません(同じエラー)
int const fin = const_cast<int const&>(newArraySize);
int deduped[fin];