Jump to content
  • Advertisement
Sign in to follow this  
Dryak

Defined Class Not Defined? Error C2027!

This topic is 3161 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

Hey guys, I'm having a little trouble with a few classes that are trying to access another class. I'm getting the message: 1>d:\rei\documents\visual studio 2008\projects\applied project\applied project\currentview.h(80) : error C2027: use of undefined type 'Player' 1> d:\rei\documents\visual studio 2008\projects\applied project\applied project\currentview.h(46) : see declaration of 'Player' Even though I've included the class as well as done forward declaration. Below is my code, can some one point out what I'm doing wrong? P.S. Also, can someone tell me what the html tag is for posting code?
#pragma once

#include "ControllerState.h"

//The include and declaration
#include "Player.h"
class Player;


//View State Class --- This class is fine... see the class below.....
class View
{
public:

	virtual float GetCameraAngleX()
	{
		return 0;
	}

	virtual float GetCameraAngleY()
	{
		return 0;
	}

	virtual void SetCameraAngleX(float value)
	{

	}

	virtual void SetCameraAngleY(float value)
	{

	}

	virtual void Update()
	{

	}
};


//Class FPS inheriting from class view
class FPS : public View
{
public:

        //Player pointer... no problems here
	Player *player;


	float fCameraAngleX;
	float fCameraAngleY;

	ControllerState *controller;

        //Constructor... no problems here  
	FPS(Player *currentPlayer, ControllerState *currentController)
	{
		this->controller = currentController;
		this->player = currentPlayer;

		fCameraAngleX = 0;
		fCameraAngleY = 0;

		//dbSetCameraToObjectOrientation ( player->id) ;


	}

	void Update()
	{

		// create a rotation axis based on controller movement
		fCameraAngleX = dbWrapValue ( fCameraAngleX + controller->GetVeiwX() );
		fCameraAngleY = dbWrapValue ( fCameraAngleY + controller->GetVeiwY() );

		////THIS FUNCTION\\\                ///When trying to access player->id and any other player variable after this, I get the error message
		dbYRotateObject( player->id,fCameraAngleX );
		dbRotateCamera ( fCameraAngleY, fCameraAngleX, 0 );

		dbPositionCamera ( player->x, player->y+85, player->z+8);
	}

	float GetCameraAngleX()
	{
		return this->fCameraAngleX;
	}

	float GetCameraAngleY()
	{
		return this->fCameraAngleY;
	}

	void SetCameraAngleX(float value)
	{
		this->fCameraAngleX = value;
	}

	void SetCameraAngleY(float value)
	{
		this->fCameraAngleY = value;
	}
};

[Magickal faeries fixed this for you while you were gone. In the mean time, read the FAQ. - Zahlman] [Edited by - Zahlman on October 27, 2009 11:21:40 PM]

Share this post


Link to post
Share on other sites
Advertisement
It looks like you're forward declaring Player after you've already included its header. This is going to screw up the compiler when it tries to find Player's definition.

Either forward declare a class in a header file and #include it in the corresponding source file, or #include it in the header file and ditch the forward declaration altogether:
// OPTION 1:

// .h file
class Player;

// .cpp file
#include "Player.h"

/* ---------------------- */

// OPTION 2:

// .h file
#include "Player.h"



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!