Sign in to follow this  
proanim

problem with classes

Recommended Posts

proanim    455
I am getting LNK2005 and it pisses me of big time. What I want to do is access varables in Class A from Class B. In this case it is Camera and Input class. Input class detects 'key down' and moves the camera, now I have initialized my classes with

[source lang="cpp"]Input Keyboard;
Camera GameCamera;[/source]

and my input check looks like this

[source lang="cpp"]bool Input::CheckInput()
{
if(IsKeyDown(VK_NUMPAD8))
GameCamera.m_pos += (GameCamera.m_target * StepScale);

if(IsKeyDown(VK_ESCAPE))
return false;

return true;
}[/source]

in main loop I use Keyboard.CheckInput(); to get input from the user.

I get three errors with LNK2005 first Camera class in input source and other two are Camera and Input classes in main source.

Both classes are initialized in their header files and no where else. What should I do to fix this problem.

Share this post


Link to post
Share on other sites
SiCrane    11839
You might want to read [url=http://www.gamedev.net/page/resources/_/technical/general-programming/organizing-code-files-in-c-and-c-r1798]this article[/url]. You seem to be having problem number four.

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