请教析造和析构函数

ifineedhelp 2006-10-21 02:04:50
析造函数如何对 指针数组或者数组 初始化(付值)。。。
请各位指点我这个菜鸟一下。。
...全文
202 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
飞哥 2006-10-21
  • 打赏
  • 举报
回复
难道你的意思是析构了再构造?

--------------
析造不是析构?
ifineedhelp 2006-10-21
  • 打赏
  • 举报
回复
我是想知道...在类的析造函数如何对他的数据成员---数组进行初始化
飞哥 2006-10-21
  • 打赏
  • 举报
回复
原型:extern void bzero(void *s, int n);

用法:#include <string.h>

功能:置字节字符串s的前n个字节为零。

说明:bzero无返回值。

举例:

// bzero.c

#include <syslib.h>
#include <string.h>

main()
{
struct
{
int a;
char s[5];
float f;
} tt;

char s[20];

bzero(&tt,sizeof(tt)); // struct initialization to zero
bzero(s,20);

clrscr();
printf("Initail Success");

getchar();
return 0;
}
Jokar 2006-10-21
  • 打赏
  • 举报
回复
没办法: 只能循环
飞哥 2006-10-21
  • 打赏
  • 举报
回复
ZeroMemory
The ZeroMemory function fills a block of memory with zeros.

VOID ZeroMemory(
PVOID Destination,
// address of block to fill with zeros
DWORD Length // size, in bytes, of block to fill with zeros
);
==============================
/* MEMSET.C: This program uses memset to
* set the first four bytes of buffer to "*".
*/

#include <memory.h>
#include <stdio.h>

void main( void )
{
char buffer[] = "This is a test of the memset function";

printf( "Before: %s\n", buffer );
memset( buffer, '*', 4 );
printf( "After: %s\n", buffer );
}

飞哥 2006-10-21
  • 打赏
  • 举报
回复
ZeroMemory(pvoid,size);

#include <windows.h>
Kusk 2006-10-21
  • 打赏
  • 举报
回复
函数种数组赋值只能通过memset((void*)array, 0, sizeof(int) * sizeof(ARRAY_SIZE))置零或者循环赋值。

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧