Sign in to follow this  
nick5454

Compile BooBoo

Recommended Posts

nick5454    142
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
dcosborn    674
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
nick5454    142
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
dcosborn    674
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
nick5454    142
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
owiley    257
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this