首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

同一个种的不同实例化,vtft的地址是一样的吗

2012-09-11 
同一个类的不同实例化,vtft的地址是一样的吗?C/C++ code有虚函数的类,在拷贝的时候,可否用memcpy, memmove

同一个类的不同实例化,vtft的地址是一样的吗?

C/C++ code
有虚函数的类,在拷贝的时候,可否用memcpy, memmove??函数是对象共用的, 那么虚函数也是共用的,调用memcpy, memmove,到底会不会把每个对象中的vtft地址给修改了。 vtft的地址是一样代码啊?关于memove有段权威的话:memmove<cstring>void * memmove ( void * destination, const void * source, size_t num );Move block of memoryCopies the values of num bytes from the location pointed by source to the memory block pointed by destination. Copying takes place as if an intermediate buffer were used, allowing the destination and source to overlap.The underlying type of the objects pointed by both the source and destination pointers are irrelevant for this function; The result is a binary copy of the data.译文:针对基本类型,即内置类型。  也就是说,这里的权威解释:只能对基本类型使用,但没有说不能对非内置类型操作。


[解决办法]
http://en.cppreference.com/w/cpp/algorithm/copy

C++ 中,memmove 已被淘汰,使用 copy 算法.

C语言的结构体可以memmove

热点排行