Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Program is all hosed up...need OOP/MFC help

Program is all hosed up...need OOP/MFC help

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++graphicsgame-devtutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CoffeeAddict19
    wrote on last edited by
    #1

    I'd really appreciate it if someone could look at these header files and give me some idea how to fix them. Basically what I have is a tic-tac-toe program in MFC. I have a main window, which is class CGameWin (inherits from CFrameWnd) and a dialog box class called CGameKeyBindingDialog (inherits from CDialog). Previously I did almost everything in CGameWin, and everything worked out fine. Then CGameWin got bloated with functions that were related to game mechanics rather than graphics or window handling, so I decided to create the class GameOperations. It does everything for the game not related to graphics or window handling. That's when everything got hosed up. Here are the class related errors I'm getting: e:\Homework\CS\CS2\Game\game_interface.h(14): error C2011: 'CGameKeyBindingDialog' : 'class' type redefinition e:\Homework\CS\CS2\Game\game_interface.h(29): error C2011: 'CGameWin' : 'class' type redefinition e:\Homework\Cs\Cs2\Game\game_operations.cpp(50): error C2065: 'CGameWinPtr' : undeclared identifier e:\Homework\Cs\Cs2\Game\game_interface.cpp(16): error C2065: 'Operations' : undeclared identifier e:\Homework\Cs\Cs2\Game\game_interface.cpp(352): error C2086: 'const AFX_MSGMAP messageMap 1' : redefinition e:\Homework\Cs\Cs2\Game\game_interface.cpp(382): error C2086: 'const AFX_MSGMAP CGameKeyBindingDialog::messageMap' : redefinition e:\Homework\Cs\Cs2\Game\game_interface.cpp(352): error C2086: 'const AFX_MSGMAP_ENTRY _messageEntries 0[]' : redefinition e:\Homework\Cs\Cs2\Game\game_interface.cpp(382): error C2086: 'const AFX_MSGMAP_ENTRY CGameKeyBindingDialog::_messageEntries[]' : redefinition game_interface.h: #ifndef GAME_INTERFACE_H #define GAME_INTEFRACE_H #include #include "game_operations.h" #include using namespace std; class CGameWin; class CGameKeyBindingDialog : public CDialog { public: CGameKeyBindingDialog(char* lpszName); BOOL OnInitDialog(); CGameWin* getMainWnd(); void setMainWnd(CGameWin* mp); void InitAll(); afx_msg void OnExitDialog(); private: CGameWin* m_pMainWnd; //pointer to main window DECLARE_MESSAGE_MAP() }; class CGameWin : public CFrameWnd { public: CGameWin(); ~CGameWin(); void PopMessageBox(LPCSTR Message, LPCSTR Title, UINT Style); afx_msg void OnPaint(); //input handling afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); //file menu "File" afx_msg void OnNewGame(); afx_msg void OnExit(); //graphics void RedrawScreen(CDC* Surface,

    C M 2 Replies Last reply
    0
    • C CoffeeAddict19

      I'd really appreciate it if someone could look at these header files and give me some idea how to fix them. Basically what I have is a tic-tac-toe program in MFC. I have a main window, which is class CGameWin (inherits from CFrameWnd) and a dialog box class called CGameKeyBindingDialog (inherits from CDialog). Previously I did almost everything in CGameWin, and everything worked out fine. Then CGameWin got bloated with functions that were related to game mechanics rather than graphics or window handling, so I decided to create the class GameOperations. It does everything for the game not related to graphics or window handling. That's when everything got hosed up. Here are the class related errors I'm getting: e:\Homework\CS\CS2\Game\game_interface.h(14): error C2011: 'CGameKeyBindingDialog' : 'class' type redefinition e:\Homework\CS\CS2\Game\game_interface.h(29): error C2011: 'CGameWin' : 'class' type redefinition e:\Homework\Cs\Cs2\Game\game_operations.cpp(50): error C2065: 'CGameWinPtr' : undeclared identifier e:\Homework\Cs\Cs2\Game\game_interface.cpp(16): error C2065: 'Operations' : undeclared identifier e:\Homework\Cs\Cs2\Game\game_interface.cpp(352): error C2086: 'const AFX_MSGMAP messageMap 1' : redefinition e:\Homework\Cs\Cs2\Game\game_interface.cpp(382): error C2086: 'const AFX_MSGMAP CGameKeyBindingDialog::messageMap' : redefinition e:\Homework\Cs\Cs2\Game\game_interface.cpp(352): error C2086: 'const AFX_MSGMAP_ENTRY _messageEntries 0[]' : redefinition e:\Homework\Cs\Cs2\Game\game_interface.cpp(382): error C2086: 'const AFX_MSGMAP_ENTRY CGameKeyBindingDialog::_messageEntries[]' : redefinition game_interface.h: #ifndef GAME_INTERFACE_H #define GAME_INTEFRACE_H #include #include "game_operations.h" #include using namespace std; class CGameWin; class CGameKeyBindingDialog : public CDialog { public: CGameKeyBindingDialog(char* lpszName); BOOL OnInitDialog(); CGameWin* getMainWnd(); void setMainWnd(CGameWin* mp); void InitAll(); afx_msg void OnExitDialog(); private: CGameWin* m_pMainWnd; //pointer to main window DECLARE_MESSAGE_MAP() }; class CGameWin : public CFrameWnd { public: CGameWin(); ~CGameWin(); void PopMessageBox(LPCSTR Message, LPCSTR Title, UINT Style); afx_msg void OnPaint(); //input handling afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); //file menu "File" afx_msg void OnNewGame(); afx_msg void OnExit(); //graphics void RedrawScreen(CDC* Surface,

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      game_interface.h #includes game_operations.h and game_operations.h #includes game_interface.h looks like you need to remove that circular dependency: either move declarations around or use forward declarations (like you do with "class CGameWin;"), to get rid of the need to do that circular include.

      image processing toolkits | batch image processing | blogging

      1 Reply Last reply
      0
      • C CoffeeAddict19

        I'd really appreciate it if someone could look at these header files and give me some idea how to fix them. Basically what I have is a tic-tac-toe program in MFC. I have a main window, which is class CGameWin (inherits from CFrameWnd) and a dialog box class called CGameKeyBindingDialog (inherits from CDialog). Previously I did almost everything in CGameWin, and everything worked out fine. Then CGameWin got bloated with functions that were related to game mechanics rather than graphics or window handling, so I decided to create the class GameOperations. It does everything for the game not related to graphics or window handling. That's when everything got hosed up. Here are the class related errors I'm getting: e:\Homework\CS\CS2\Game\game_interface.h(14): error C2011: 'CGameKeyBindingDialog' : 'class' type redefinition e:\Homework\CS\CS2\Game\game_interface.h(29): error C2011: 'CGameWin' : 'class' type redefinition e:\Homework\Cs\Cs2\Game\game_operations.cpp(50): error C2065: 'CGameWinPtr' : undeclared identifier e:\Homework\Cs\Cs2\Game\game_interface.cpp(16): error C2065: 'Operations' : undeclared identifier e:\Homework\Cs\Cs2\Game\game_interface.cpp(352): error C2086: 'const AFX_MSGMAP messageMap 1' : redefinition e:\Homework\Cs\Cs2\Game\game_interface.cpp(382): error C2086: 'const AFX_MSGMAP CGameKeyBindingDialog::messageMap' : redefinition e:\Homework\Cs\Cs2\Game\game_interface.cpp(352): error C2086: 'const AFX_MSGMAP_ENTRY _messageEntries 0[]' : redefinition e:\Homework\Cs\Cs2\Game\game_interface.cpp(382): error C2086: 'const AFX_MSGMAP_ENTRY CGameKeyBindingDialog::_messageEntries[]' : redefinition game_interface.h: #ifndef GAME_INTERFACE_H #define GAME_INTEFRACE_H #include #include "game_operations.h" #include using namespace std; class CGameWin; class CGameKeyBindingDialog : public CDialog { public: CGameKeyBindingDialog(char* lpszName); BOOL OnInitDialog(); CGameWin* getMainWnd(); void setMainWnd(CGameWin* mp); void InitAll(); afx_msg void OnExitDialog(); private: CGameWin* m_pMainWnd; //pointer to main window DECLARE_MESSAGE_MAP() }; class CGameWin : public CFrameWnd { public: CGameWin(); ~CGameWin(); void PopMessageBox(LPCSTR Message, LPCSTR Title, UINT Style); afx_msg void OnPaint(); //input handling afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); //file menu "File" afx_msg void OnNewGame(); afx_msg void OnExit(); //graphics void RedrawScreen(CDC* Surface,

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        Try this (I'll just post the related changes in the header files)...

        #ifndef GAME_INTERFACE_H
        #define GAME_INTEFRACE_H

        #include <afxwin.h>
        #include "game_operations.h"
        #include <defenitions.h>

        using namespace std;

        class CGameKeyBindingDialog : public CDialog
        {

        #ifndef GAME_OPERATIONS_H
        #define GAME_OPERATIONS_H

        #include <defenitions.h>

        class CGameWin;

        using namespace std;

        class GameOperations
        {

        In game_operations.cpp, include in this order

        #include "game_operations.h"
        #include "game_interface.h"

        C 1 Reply Last reply
        0
        • M Mark Salsbery

          Try this (I'll just post the related changes in the header files)...

          #ifndef GAME_INTERFACE_H
          #define GAME_INTEFRACE_H

          #include <afxwin.h>
          #include "game_operations.h"
          #include <defenitions.h>

          using namespace std;

          class CGameKeyBindingDialog : public CDialog
          {

          #ifndef GAME_OPERATIONS_H
          #define GAME_OPERATIONS_H

          #include <defenitions.h>

          class CGameWin;

          using namespace std;

          class GameOperations
          {

          In game_operations.cpp, include in this order

          #include "game_operations.h"
          #include "game_interface.h"

          C Offline
          C Offline
          CoffeeAddict19
          wrote on last edited by
          #4

          Thank you. :) Got it working now. Just got to finish the AI and put in some eye candy and it should be ready. :) :) :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups