Jump to content
  • Advertisement
Sign in to follow this  
nick5454

Compile BooBoo

This topic is 4933 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a main.cpp I create a class called class MyApp2 : public CD3DApplication in main.cpp it works fine, but when I move the class to its own cpp/h the a Cannot access public member Create ( which is CD3DApplication::Create ) Is it the place of my included or a patch, or what? Please help. nick

Share this post


Link to post
Share on other sites
Advertisement
Did you fail to #include the header that defines CD3DApplication where necessary in your new cpp/h unit?
You might consider posting relevent source code if its not too big.

Share this post


Link to post
Share on other sites
my main.cpp
#define STRICT
#include <windows.h>
#include <math.h>
#include <stdio.h>


#include <D3DX9.h>
#include "DXUtil.h"
#include "D3DEnumeration.h"
#include "D3DSettings.h"
#include "D3DApp.h"
#include "D3DFile.h"
#include "D3DFont.h"
#include "D3DUtil.h"

#include "resource.h"
#include "MyApp.h"



//LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
//VOID Render();

char szWinName[] = "MyWm";
BOOL bActive = TRUE;


class CMyApp2 : public CD3DApplication
{
public:
CMyApp2();
};

CMyApp2::CMyApp2()
{
}


INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT)
{
// CMyApp2 d3dApp; works fine
CMyApp d3dApp;


if( FAILED( d3dApp.Create( hInst )))
return 0;

return d3dApp.Run();


//return 0;
}

the MyApp cpp/h file

.h


.cpp
// MyApp.cpp: implementation of the CMyApp class.
//
//////////////////////////////////////////////////////////////////////
#include <math.h>
#include <stdio.h>
#include <Windows.h>

#include <D3DX9.h>
#include "DXUtil.h"
#include "D3DEnumeration.h"
#include "D3DSettings.h"
#include "D3DApp.h"
#include "D3DFile.h"
#include "D3DFont.h"
#include "D3DUtil.h"


#include "MyApp.h"

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

CMyApp::CMyApp()
{

}

CMyApp::~CMyApp()
{

}

LRESULT CMyApp::MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return S_OK;
}

HRESULT CMyApp::ConfirmDevice( D3DCAPS9 *pCaps, DWORD dwBehavior, D3DFORMAT adapterFormat, D3DFORMAT backBufferFormat )
{
return S_OK;
}

HRESULT CMyApp::CreateCube( CUBEVERTEX *pVertices, WORD *pIndices )
{
return S_OK;
}

HRESULT CMyApp::DeleteDeviceObjects()
{
return S_OK;
}

HRESULT CMyApp::FinalCleanup()
{
return S_OK;
}

HRESULT CMyApp::FrameMove()
{
return S_OK;
}

HRESULT CMyApp::InitDeviceObjects()
{
return S_OK;
}

HRESULT CMyApp::InvalidateDeviceObjects()
{
return S_OK;
}

HRESULT CMyApp::OneTimeSceneInit()
{
return S_OK;
}

HRESULT CMyApp::Render()
{
return S_OK;
}

HRESULT CMyApp::RestoreDeviceObjects()
{
return S_OK;
}

HRESULT CMyApp::SetLights()
{
return S_OK;
}

Share this post


Link to post
Share on other sites
Ok it looks like you're defining your MyApp class interface in your main.cpp file. As such, MyApp.cpp can't see it. Instead, define it (just the interface) in the MyApp.h file and, since you've #included MyApp.h in main.cpp and MyApp.cpp, it should work.

Share this post


Link to post
Share on other sites
yeah thats what gets me.

I the MyApp2 is defined in main.cpp and it works fine. But when I define it in MyApp.cpp. and .h if gives at the error.

Iths like the main cant a the .h file or is the class not listed in D3DApp.h ?

nick

Share this post


Link to post
Share on other sites
Thats for the help

The goof whas tis:

class MyApp : CD3DApplication

I what saying an interface, duh ( too much stipidity on my part )

Share this post


Link to post
Share on other sites
class CMyApp2 : public CD3DApplication
{
public:
CMyApp2();
};

CMyApp2::CMyApp2()
{
}



what is this in the main cpp file ??? and it need its own cpp file or it can stay in main but if it is add to its own make sure to delcare the class in a header than link it. also and your header other headers to that file.
something like
MyApp.h

#define STRICT
#include <windows.h> // handles windows specific
#include <math.h> // useful functions for math operations
#include <stdio.h> // standard c++ stuff
#include <D3DX9.h> // directx 3d ninth release
#include "DXUtil.h" // directx utility
#include "D3DEnumeration.h" //directx 3d
#include "D3DSettings.h" // 3d settings
#include "D3DApp.h" // 3d application
#include "D3DFile.h" // 3d file handler
#include "D3DFont.h" // 3d font
#include "D3DUtil.h" //3d utility

#include "resource.h"


class CMyApp : public CD3DApplication
{
public:
CMyApp();
.....
};





MyApp.cpp


#include "MyApp.h"

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

CMyApp::CMyApp()
{

}

CMyApp::~CMyApp()
{

}

LRESULT CMyApp::MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return S_OK;
}

HRESULT CMyApp::ConfirmDevice( D3DCAPS9 *pCaps, DWORD dwBehavior, D3DFORMAT adapterFormat, D3DFORMAT backBufferFormat )
{
return S_OK;
}

HRESULT CMyApp::CreateCube( CUBEVERTEX *pVertices, WORD *pIndices )
{
return S_OK;
}

HRESULT CMyApp::DeleteDeviceObjects()
{
return S_OK;
}

HRESULT CMyApp::FinalCleanup()
{
return S_OK;
}

HRESULT CMyApp::FrameMove()
{
return S_OK;
}

HRESULT CMyApp::InitDeviceObjects()
{
return S_OK;
}

HRESULT CMyApp::InvalidateDeviceObjects()
{
return S_OK;
}

HRESULT CMyApp::OneTimeSceneInit()
{
return S_OK;
}

HRESULT CMyApp::Render()
{
return S_OK;
}

HRESULT CMyApp::RestoreDeviceObjects()
{
return S_OK;
}

HRESULT CMyApp::SetLights()
{
return S_OK;
}




main.cpp


#include "MyApp.h"



//LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
//VOID Render();

char szWinName[] = "MyWm";
BOOL bActive = TRUE;
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT)
{
// CMyApp2 d3dApp; works fine
CMyApp d3dApp;


if( FAILED( d3dApp.Create( hInst )))
{
return(0);
}

return d3dApp.Run();

//start using brackets-{}-and parthesis-()
//i would write return(0); not return 0 just for clarity
return 0;
/*This is a good practice and plus it organizes code like the way my english teachers always argue me to do!*/
}





Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!