0

C++ では配列の動的割り当てができないにもかかわらず、以下のコードのコンパイルが成功するのはなぜですか? コメントのコメントを外すと、エラーが表示されますか??

#include<iostream>
#include <string>
using namespace std;
int main()
{
    string aa;
    cin>>aa;
    int a[aa.size()];// though allocating the array dynamically the compilation succeeded
    cout<<"COMPILATION SUCCESS"<<endl;

    /*char *p;
    cin>>p;
    int y=sizeof(p);
    int b[y];
    cout<<"COMPILATION ERROR"<<endl;
    */


    /*
    int tt;
    cin>>tt;
    int c[tt];//  shows error
    cout<<"ERROR";
    */
}
4

1 に答える 1