I'm reading the book C++ Primer 5th Edition. On Page 477 a function get_size() is used to allocate an array of int , as pasted below.

// call get_size to determine how many ints to allocate
int *pia = new int[get_size()]; // pia points to the first of these ints 

I have tried:

#include <new>
#include <memory>

but didn't work. I googled this function as well, but still in vain.Which header should I include before it can be used in my code?

有帮助吗?

解决方案

get_size() should be an user defined function here. Don't need to waste your time finding its header.

其他提示

That's just a random thing the book used as a example of the type of information to pass to new, e.g., the amount of the memory to allocate. It's not an actual function, at least not in the standard library.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top