Hi all,
i'm using VC++ .NET 7.0 and have the following probem with the following code.
Code:
// Dummy.h
//
#pragma once
class Dummy
{
public:
Dummy(void);
~Dummy(void);
void CpyStr(char *test);
private:
char *clone_str;
};
// Dummy.cpp
//
#include "StdAfx.h"
#include ".\dummy.h"
#include <fstream>
using namespace std;
Dummy::Dummy(void)
{
}
Dummy::~Dummy(void)
{
if (clone_str)
delete clone_str;
}
void Dummy::CpyStr(char *test)
{
clone_str = new char[strlen(test)];
strcpy(clone_str, test);
cout << "Clone: " << clone_str << "\n";
}
// destructorTest.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
//
#include "stdafx.h"
#include "Dummy.h"
Dummy MyDummy;
int _tmain(int argc, _TCHAR* argv[])
{
MyDummy.CpyStr ("TestString");
return 0;
}
the code in the destructor crashes the programm. I get the dialog a seen in the image below.
Can somebody please tell me why it is so ?