请教const问题
inline void MemCopy(void *_d, const void *_s, int size){
char *d = (char *)_d;
const char *s = (const char *)_s;
const char *e = s + size;
for( ; s < e; d++, s++ )
*d = *s;
}
在该函数中s 指针定义为const,但在后面又s++ ,看起来矛盾但是编译没有错误?
搜索更多相关的解决方案:
const
----------------解决方案--------------------------------------------------------
const char *s表示s是一个指向常字符型的指针,其指向的字符型不可变,但*s可变,因此可以s++
[此贴子已经被作者于2006-9-27 12:57:21编辑过]
----------------解决方案--------------------------------------------------------
谢谢forice.
----------------解决方案--------------------------------------------------------