Sign-up....

new 和delete 的问题

我的程序如下:

#include "stdafx.h"

#include <iostream.h>

#include <string.h>

#include <stdlib.h>

class Num

{

public:

Num(int x);

~Num();

private:

int Number;

char* CNum;

};

Num::Num(int x)

{

Number=x;

char buff[10];

itoa(Number,buff,10);

CNum=new char[strlen(buff)];

strcpy(CNum,buff);

cout<<Num::Number<<":"<<Num::CNum<<endl;

}

Num::~Num()

{

delete[] Num::CNum;

}

int main(int argc, char* argv[])

{

Num(500);

printf("Hello World!\n");

return 0;

}

运行在delete的地方就回出现

Debug Error

DAMAGE:after Normal block (#43) at 0x00430070.

(Press Retry to debug the appiication)

请帮我解决一下是什么问题啊。

谢谢!

[634 byte] By [暮色苍茫] at [2007-8-15 11:06:31]

C/C++

All Classified