如图,为啥申请了44字节的内存,而不是40字节。
类对象4字节,申请了10个,不应该是40字节吗?
附代码
#include <iostream>
void* operator new [](std::size_t size)
{
std::cout << "operator new [] " << std::endl;
std::cout << "new [] size is " << size << std::endl;
return std::malloc(size);
}
class Foo {
public:
Foo() { std::cout << "Foo()" << std::endl; }
virtual ~Foo() { std::cout << "~Foo()" << std::endl; }
};
int main()
{
char* test = new char[700];
Foo* yzm_foo = new Foo[10];
std::cout << "size of test is " << sizeof(test) << "\n" << std::endl;
delete test;
return 0;
}