error C2573: 'GameWnd' : cannot delete pointers to objects of this type

Hi, I am a very beginner for C++, and I'm learning a tutorial for beginners. In Chapter 15, the tutor jumps to MFC about how to create a Game -Maze. I followed his steps, and I wasn't wrong. Now I wanted to create it again, just after a few steps my compiler VC 6.0 always reminded me of errors. I checked and recreated the code for several times yesterday and today, but I don't figure out.

Here's the error: error C2573: 'GameWnd' : cannot delete pointers to objects of this type; the class has no non-placement overload for 'operator delete'.
Use ::delete, or add 'operator delete(void*)' to the class


The compiler points to Line 21 about the error.

Should I post all the "head" and "cpp" in order to solve the problem? Please advise. I don't know how to appropriately post the context.

Would anyone please help? Many thanks



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// GameWnd.cpp : implementation file
//

//#include "stdafx.h"
#include "Game.h"
#include "GameWnd.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// GameWnd

IMPLEMENT_DYNCREATE(GameWnd, CFrameWnd)

GameWnd::GameWnd()
{
}

GameWnd::~GameWnd()
{
}


BEGIN_MESSAGE_MAP(GameWnd, CFrameWnd)
	//{{AFX_MSG_MAP(GameWnd)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// GameWnd message handlers 
Last edited on
What is your C++ tutor?
Sound like you try to call a member function/operator of GameWnd that does not exist.
Best to show us the whole GameWnd class.

Can you post the link to the tutorial as well ?
Last edited on
Thank you very much for your responses. I bought the book which has videos. It is not from the Internet. I retried again with new file name:Game100

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#if !defined(AFX_GAMEWND_H__33955499_B4D4_4E75_BFDF_C3A1BA035AC7__INCLUDED_)
#define AFX_GAMEWND_H__33955499_B4D4_4E75_BFDF_C3A1BA035AC7__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// GameWnd.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// GameWnd frame

class GameWnd : public CFrameWnd
{
	DECLARE_DYNCREATE(GameWnd)
public:
	GameWnd();           // protected constructor used by dynamic creation

// Attributes
public:

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(GameWnd)
	//}}AFX_VIRTUAL

// Implementation
protected:
	virtual ~GameWnd();

	// Generated message map functions
	//{{AFX_MSG(GameWnd)
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_GAMEWND_H__33955499_B4D4_4E75_BFDF_C3A1BA035AC7__INCLUDED_) 



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// GameWnd.cpp : implementation file
//

//#include "stdafx.h"
#include "Game100.h"
#include "GameWnd.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// GameWnd

IMPLEMENT_DYNCREATE(GameWnd, CFrameWnd)

GameWnd::GameWnd()
{
}

GameWnd::~GameWnd()
{
}


BEGIN_MESSAGE_MAP(GameWnd, CFrameWnd)
	//{{AFX_MSG_MAP(GameWnd)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// GameWnd message handlers 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// GameApp.h: interface for the GameApp class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_GAMEAPP_H__D2D4D257_3E69_41BF_B513_BE07673B2984__INCLUDED_)
#define AFX_GAMEAPP_H__D2D4D257_3E69_41BF_B513_BE07673B2984__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class GameApp : public CWinApp  
{
public:
	GameApp();
	virtual ~GameApp();

};

#endif // !defined(AFX_GAMEAPP_H__D2D4D257_3E69_41BF_B513_BE07673B2984__INCLUDED_) 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// GameApp.cpp: implementation of the GameApp class.
//
//////////////////////////////////////////////////////////////////////

#include "Game100.h"
#include "game100.h"
#include "GameApp.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

GameApp::GameApp()
{

}

GameApp::~GameApp()
{

}


And there's a Game.rc file which I don't include any resource so far.


Is it possible you and anyone help me to find out the problem at your convenience? Many thanks!
There are no obvious faults in your code so it's difficult to say where the problem is.
Here is a template I use for MFC demos. Try if it works for you.
https://www.dropbox.com/sh/vfqts8xfbv4qgj5/AABL11f2NWNjFqQme0-QaSYAa?dl=0
BTW Why do you still use such an old IDE like VC 6.0 ?
You can get Visual Studio Communities editions for free - they also have MFC included.
Thank you so much for taking your precious time to help me, Thomas.

I found the problem myself. Mostly I am very careless. Today I followed the video very carefully step by step, what the tutor demonstrated but still failed. I hadn't gotten the wrong warming before. I started speculating it might be due to the damage of the software. I reinstalled just now. Hurray, I don't get the warning again.

I teach myself C++ from scratch. I didn't hear about other compiler until very recently. I still use it because the tutor on the video used it. I tried to install VS but I don't even know how to creat the a new project and I don't know where "insert", etc. are.

I know the tutorial I used is not very desireable. It's outdated. When I posed the code I transcribed from there and asked on the forum here, and some experienced forumites frowned upon that. For example, they told me to avoid using "using namespace std", but the tutor instructed.

However I think that is very helpful for me, as I knew nothing about programming before, because the tutor demonstrated every step. I have the book named C++ Primer Plus. I thrumbed through it, but it is still difficult for me. I'll adopt another better tutorial when I finish this.

I was so frustrated that I couldn't move on along the tutorial. I really really appreciate you would like to help.

Have a great day! :)

Last edited on
Topic archived. No new replies allowed.