Defining Arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I am very confused about the way arrays are initialized under g++. (I am using Red Hat Linux 9)

	int size;
	cin >> size;
	int myarray[size];

According to what I had known earlier this should not be possible since the size of the array should be a constant.

But this seems to work perfectly under g++. To my knowledge in Standard C++ you are not allowed to use a variable during a array declaration.

If you can create dynamic arrays this way, why bother using dynamic arrays using pointers ?

e.g.

	int size;
	cin >> size;
	int * pmyarray = new int[size];


Nuwan



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux