If you have to suggest using operator new or operator new[], then they probably don't know how to deallocate memory as well. You may have implied it, but that doesn't mean they know that.Yumtard wrote:I thought using delete after new was implied
chilli said we need to know size of the array at the compile
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: chilli said we need to know size of the array at the com
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: chilli said we need to know size of the array at the com
It seems like it's actually possible to some extent in C++11 or maybe it's just the gcc compiler I'm using, but I was able to make a function like this work:
I'm thinking it must automatically do memory allocation and de-allocation behind the scenes, but I don't think it would be allocating on the stack.
Code: Select all
void my_func(int arr_size)
{
char myArray[arr_size];
...
}
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: chilli said we need to know size of the array at the com
The GCC compiler probably supports variable length arrays, which in C is a thing. In C++, I do not believe it is supported. So the GCC compiler allowing variable length arrays for C++ code would be a non-conforming extension.
Variable Length Arrays
Variable Length Arrays
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: chilli said we need to know size of the array at the com
Interesting bit of knowledge, good to know why my code is working lol.
Re: chilli said we need to know size of the array at the com
I wouldn't have believed it. Usually it is microsoft who is always fucking up conformation
Chili
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: chilli said we need to know size of the array at the com
I figured as much, glad I was able to find something to back my claim.chili wrote:I wouldn't have believed it. Usually it is microsoft who is always fucking up conformation
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com