   Some errors with using constructors.
  I'm trying to use a constructor but i get this error.1>c:\documents and settings\directx\my documents\visual studio 2008\projects\pong_game\pong_game\winmian.cpp(88) : error C2273: 'function-style cast' : illegal as right side of '->' operator1>Build log was saved at "file://c:\Documents and Settings\DirectX\My Documents\Visual Studio 2008\Projects\Pong_game\Pong_game\Debug\BuildLog.htm"1>Pong_game - 1 error(s), 0 warning(s)========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========and my source is this:#include <windows.h>#include <time.h>#include "Bin/CDirect3D9.h"ATOM MyRegisterClass(HINSTANCE hInstance);LRESULT CALLBACK WinProc(HWND hwnd, UINT message,WPARAM wParam,LPARAM lParam);//Global variablesHWND hwnd;HINSTANCE hInstance;#define APPTITLE L"Pong Game"CDirect3D9* Direct3D = new CDirect3D9();LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){switch( message ){case WM_DESTROY:PostQuitMessage(0);return 0;}return DefWindowProc(hwnd, message, wParam, lParam);}ATOM MyRegisterClass(HINSTANCE hInstance){WNDCLASSEX Window_Class;Window_Class.cbSize= sizeof(WNDCLASSEX);Window_Class.style= CS_HREDRAW | CS_VREDRAW;Window_Class.lpfnWndProc = (WNDPROC)WinProc;Window_Class.cbClsExtra = 0;Window_Class.cbWndExtra= 0;Window_Class.hInstance= hInstance;Window_Class.hIcon= NULL;Window_Class.hCursor= LoadCursor(NULL,IDC_ARROW);Window_Class.hbrBackground= (HBRUSH)GetStockObject(WHITE_BRUSH);Window_Class.lpszClassName= APPTITLE;Window_Class.lpszMenuName= NULL;Window_Class.hIconSm= NULL;return RegisterClassEx(&Window_Class);}int WINAPI WinMain(HINSTANCE hInstance,   HINSTANCE hPrevInstance,   LPSTR lpCmdLine,   int nCmdShow){MSG msg;MyRegisterClass(hInstance);hwnd = CreateWindow(APPTITLE,APPTITLE,WS_OVERLAPPEDWINDOW,10,10,500,500,NULL,NULL,hInstance,NULL);if(!hwnd){return 0;}Direct3D->CDirect3D9();if(!Direct3D->InitDirect3D9(hwnd,500,500,false)){return 0;}ShowWindow(hwnd,nCmdShow);UpdateWindow(hwnd);int done = 0;while(!done){if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){if(msg.message == WM_QUIT)done = 1;TranslateMessage(&msg);DispatchMessage(&msg);}else{Direct3D->Render();}}return msg.wParam;}and here is my Direct3D class. is it even worth it to use classes? cause yeah every time i uses classes i get access violations.#ifndef CDIRECT3D_NINE#define CDIRECT3D_NINE#include <windows.h>#include <d3d9.h>#include <d3dx9.h>#pragma comment(lib,"d3d9.lib")#pragma comment(lib,"d3dx9.lib")class CDirect3D9{public:CDirect3D9();~CDirect3D9();int InitDirect3D9(HWND hwnd, int width, int height,bool fullscreen);LPDIRECT3D9* ReturnDirect3D9();LPDIRECT3DDEVICE9* ReturnDirect3DDevice9();LPDIRECT3DSURFACE9* ReturnBackBuffer();void Render();private:LPDIRECT3D9 Direct3D9;LPDIRECT3DDEVICE9 Direct3DDevice9;LPDIRECT3DSURFACE9 BackBuffer;D3DPRESENT_PARAMETERS Present_Params;};#endifand here is my CDirect3D9 source file#include "CDirect3D9.h"CDirect3D9::CDirect3D9(){Direct3D9 = NULL;Direct3DDevice9 = NULL;BackBuffer = NULL;}CDirect3D9::~CDirect3D9(){Direct3D9->Release();Direct3DDevice9->Release();BackBuffer->Release();}int CDirect3D9::InitDirect3D9(HWND hwnd, int width, int height, bool fullscreen){Direct3D9 = Direct3DCreate9(D3D_SDK_VERSION);if(!Direct3D9){MessageBoxA(NULL,"Direct3D9 could not be created","Error",MB_OK);return 1;}ZeroMemory(&Present_Params,sizeof(Present_Params));Present_Params.Windowed= (!fullscreen);Present_Params.BackBufferCount= 1;Present_Params.BackBufferFormat= D3DFMT_X8R8G8B8;Present_Params.BackBufferWidth= width;Present_Params.BackBufferHeight = height;Present_Params.hDeviceWindow= hwnd;Direct3D9->CheckDeviceType(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,D3DFMT_X8R8G8B8,D3DFMT_X8R8G8B8,false);HRESULT result = Direct3D9->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&Present_Params,&Direct3DDevice9);if(FAILED(result)){MessageBoxA(NULL,"The device could not be created","Error",MB_OK);}if(FAILED(Direct3DDevice9->Clear(0,0,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,1)));return 0;if(FAILED(Direct3DDevice9->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&BackBuffer)));return 0;return 1;}void CDirect3D9::Render(){if(SUCCEEDED(Direct3DDevice9->Clear(0,0,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,1)));if(SUCCEEDED(Direct3DDevice9->BeginScene())){Direct3DDevice9->EndScene();}Direct3DDevice9->Present(NULL,NULL,NULL,NULL);}Any help you can give me i'd appreciate it. Maybe i need to study C++ more before i get into game dev? might save me some head aches.   
  A constructor is called automagically when an instance is constructed.In C++ you do not call constructors directly, so this is wrong: Direct3D->CDirect3D9();The constructor was called here: CDirect3D9* Direct3D = new CDirect3D9();   ;  Ohb.well, for some reason, i still get access violations and the device doesn't want to create.....this is making me mad.....I write the code as i remember it it compiles but of course it wont run because it says that Direct3DDevice9 is a null pointer, so i don't know what to do about these access violations   ;  Well, where and when do these access violations occur?I don't spot anything obvious, although this code needs fixing:if(FAILED(result)){MessageBoxA(NULL,"The device could not be created","Error",MB_OK);}if(FAILED(Direct3DDevice9->Clear(0,0,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,1)));return 0;if(FAILED(Direct3DDevice9->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&BackBuffer)));return 0;You don't return an error if the device fails to initialise, and those semi-colons on the end of the last two if-statments need to be removed, otherwise the function will always fail.   ;  For some reason, i initialized the Variables to NULL but i still get accesss violations in the InitDirect3D function. it points to Direct3DDevice9 and it's also telling me that the expression cannot be evaluated. and that BackBuffer is  0x0000000 and giving me some access violation with other variables such as Present_Rarams.int CDirect3D9::InitDirect3D9(HWND hwnd, int width, int height, bool fullscreen){Direct3D9 = Direct3DCreate9(D3D_SDK_VERSION);if(!Direct3D9){MessageBoxA(NULL,"Direct3D9 could not be created","Error",MB_OK);return 1;}ZeroMemory(&Present_Params,sizeof(Present_Params));Present_Params.Windowed= (!fullscreen);Present_Params.BackBufferCount= 1;Present_Params.BackBufferFormat= D3DFMT_X8R8G8B8;Present_Params.BackBufferWidth= width;Present_Params.BackBufferHeight = height;Present_Params.hDeviceWindow= hwnd;HRESULT result = Direct3D9->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&Present_Params,&Direct3DDevice9);Direct3D9->CheckDeviceType(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,D3DFMT_X8R8G8B8,D3DFMT_X8R8G8B8,false);if(FAILED(result)){MessageBoxA(NULL,"The device could not be created","Error",MB_OK);}Direct3DDevice9->Clear(0,0,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,1);Direct3DDevice9->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&BackBuffer);return 1;}there has to be something i can do to make it so i never get Access violations ever again. They are driving me crazy!!! I suppose using a namespace would be better? all i know is that i want to be able to make a class that can handle Direct3D the guy in Beginning Game Programming did it and yes i've looked at it. there's nothing different that i can see from mine   ;  I just tried to use Direct3D with out puitting it into a class and it worked. I guess C++ doesn't like it when you use DirectX inside a class. call me crazy but that's what it seems like.   