Sign in to follow this  
ender_341

Compiler finding class as member variable without type

Recommended Posts

My problem is this, when i try to create a pointer of my input class in my battle class it gives me the errors below. From what I am reading it is finding the "Input" before "*m_Input" to be a variable while it is the type. has anyone had a similar problem before that may be able to shed some light on what I'm doing wrong? Thanks in advance to anyone who can help. [edit] just thought I should note, the Input Class works fine elsewhere in my program. errors: Battle.h(34) : error C2143: syntax error : missing ';' before '*' Battle.h(34) : error C2501: 'Battle::Input' : missing storage-class or type specifiers Battle.h(34) : error C2501: 'Battle::m_Input' : missing storage-class or type specifiers Battle.h(34) : error C2143: syntax error : missing ';' before '*' Battle.h(34) : error C2501: 'Battle::Input' : missing storage-class or type specifiers Battle.h(34) : error C2501: 'Battle::m_Input' : missing storage-class or type specifiers Input.h
// -- Input.h ------------ //
// -- Matthew Sorenson --- //
// -- 04/18/06 ----------- //

#include <SDL.h>

#ifndef INPUT_H
#define INPUT_H

class Input
{
public:
	Input( SDL_Event *Event );
	~Input( void );

	void readInput( void );
	bool getInput( Uint32 Key );

	bool windowClosed( );

private:
	SDL_Event *event;
	bool keysHeld[323];
	bool iswindowClosed;
};

#endif




Input.cpp
// -- Input.cpp ---------- //
// -- Matthew Sorenson --- //
// -- 04/18/06 ----------- //

#include <SDL.h>
#include "Input.h"

Input::Input( SDL_Event *Event )
{
	this->event = Event;
	for( Uint32 i = 0; i < 323; i++ )
	{
		this->keysHeld[i] = false;
	}
	this->iswindowClosed = false;
}

Input::~Input( void )
{
}

void Input::readInput( void )
{
	if ( this->event->type == SDL_KEYDOWN )
	{
		keysHeld[this->event->key.keysym.sym] = true;
	}
	if ( event->type == SDL_KEYUP )
	{
		keysHeld[event->key.keysym.sym] = false;
	}
}

bool Input::getInput( Uint32 Key )
{
	return this->keysHeld[ Key ];
}

bool Input::windowClosed( void )
{
	return windowClosed;
}




Battle.h
// -- Battle.h ----------- //
// -- Matthew Sorenson --- //
// -- 04/18/06 ----------- //

#ifndef BATTLE_H
#define BATTLE_H

#include <SDL.h>
#include <string>

#include "Tile.h"
#include "Timer.h"
#include "Input.h"
#include "TextBox.h"
#include "Graphics.h"
#include "Character.h"

class Battle
{
public:
	Battle( Character *PC, Character *NPC, Tile *tile, Graphics *graph, TextBox *text );

	~Battle( void );

	void Draw( void );
	void Input( void );
	void NPCTurn( void ); 
private:
	Timer *PCcounter;
	Timer *NPCcounter;
	Uint32 turnNumber;
	Uint32 curserSelect;

	Input		*m_Input;
	Tile		*m_Tile;
	TextBox		*m_TextBox;
	Graphics	*m_Graphics;
	Character	*Hero;
	Character	*Enemy;
};
#endif




Battle.cpp
// -- Battle.cpp --------- //
// -- Matthew Sorenson --- //
// -- 04/18/06 ----------- //

#include "Character.h"
#include "Graphics.h"
#include "TextBox.h"
#include "Battle.h"
#include "Input.h"
#include "Timer.h"
#include "Tile.h"

Battle::Battle( Character *PC, Character *NPC, Tile *tile, Graphics *graph, TextBox *text )
{
	this->Hero = PC;
	this->Enemy = NPC;
	this->PCcounter = new Timer( );
	this->NPCcounter = new Timer( );
	this->m_TextBox = text;
	this->curserSelect = 0;
}

Battle::~Battle( void )
{
	delete this->PCcounter;
	delete this->NPCcounter;
}

void Battle::Input( void )
{
}

void Battle::Draw( void )
{
	this->m_TextBox->BattleBox(0, this->Hero->getHP( ), this->Hero->GetmaxHP( ), this->Hero->getName( ) );
}

void Battle::NPCTurn( void )
{
	if( this->Enemy->getHP( ) < this->Enemy->GetmaxHP() / 10 )
	{
		// Heal
	}
	else
	{
		// Attack
	}
}




[Edited by - ender_341 on April 23, 2006 9:27:32 PM]

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