添加到内存地址错误 [英] Adding to a Memory Address Error
本文介绍了添加到内存地址错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这不会在VSC ++ 2008中编译。
void * toSendMemory2 = toSendMemory + 4;
我为什么不知道,虽然我确信这很蠢。 :P $ <$>
$ <$> c> T * 指针将增加 sizeof(T)* N
字节。 sizeof(void)
是无意义的,因此不允许对 void *
进行指针运算。
This doesn't compile in VSC++ 2008.
void* toSendMemory2 = toSendMemory + 4;
I am at a loss at why, though I am sure it's very stupid of me. :P
解决方案
When you add N
to a T*
the pointer will be incremented by sizeof(T) * N
bytes. sizeof(void)
is nonsensical, so pointer arithmetic over void*
is not allowed.
这篇关于添加到内存地址错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文