Sign in to follow this  
Mizipzor

Problems with console class

Recommended Posts

I want to create a quake like console. But the compiler says "missing storage class" and "syntax error"... but I cant really see whats wrong, probarly just forgot a ; somewhere but I cant manage to find it. Console.h
#ifndef _CONSOLE
#define _CONSOLE

#include "FontSystem.h"

#define CONSOLE_LINES 15

class Console {
protected:
	// Singleton class
	static Console* m_pInstance;
	Console( void );

private:
	std::vector <std::string> ConsoleLine;	// all the lines in the console window

	FontSystem*	Font;	// so we can draw text

public:
	// Singleton ---
	static Console* GetInstance( void ) {
		if ( !m_pInstance )
			m_pInstance = new Console();
		return m_pInstance;
	};

	void	DrawConsole();	// draws the console window, background and all lines
	//void	TakeInput();	// the prompt
};

#endif

Console.cpp
#include "Console.h"

Console* Console::m_pInstance = 0;

Console::Console() {	
	Font->GetInstance()
	ConsoleLine.resize( CONSOLE_LINES, "0" );
}

void Console::DrawConsole() {
	while( ConsoleLine.size() > CONSOLE_LINES )
		ConsoleLine.erase( ConsoleLine.begin() );	// erase the begin element (top line) until we have the size we want

	for(int i = 0; i < CONSOLE_LINES; i++)
		Font->DrawString( ConsoleLine[i], 0, Font->GetCharSize() * i );
}



Thats the code... Its so short and Im getting so many errors, anyone can see what Im doing wrong? Errors:
------ Build started: Project: TileSystem, Configuration: Debug Win32 ------

Compiling...
Console.cpp
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(3) : error C2143: syntax error : missing ';' before '*'
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(3) : error C2501: 'Console' : missing storage-class or type specifiers
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(3) : error C2825: 'Console::m_pInstance': cannot form a qualified name
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(3) : error C2039: 'm_pInstance' : is not a member of 'operator``global namespace'''
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(3) : error C2146: syntax error : missing ';' before identifier 'm_pInstance'
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(3) : error C2501: 'Console' : missing storage-class or type specifiers
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(3) : error C2040: 'Console' : 'int *' differs in levels of indirection from 'int'
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(3) : error C2501: 'm_pInstance' : missing storage-class or type specifiers
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(5) : error C2825: 'Console::Console': cannot form a qualified name
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(5) : error C2143: syntax error : missing ';' before 'Console'
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(5) : error C2501: 'Console' : missing storage-class or type specifiers
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(5) : error C2086: 'int Console' : redefinition
        d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(3) : see declaration of 'Console'
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(5) : error C2063: 'Console' : not a function
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(5) : error C2373: 'Console' : redefinition; different type modifiers
        d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(3) : see declaration of 'Console'
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(5) : error C2239: unexpected token '{' following declaration of 'Console'
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(10) : error C2825: 'Console::DrawConsole': cannot form a qualified name
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(10) : error C2039: 'DrawConsole' : is not a member of 'operator``global namespace'''
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(10) : error C2146: syntax error : missing ';' before identifier 'DrawConsole'
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(10) : error C2182: 'Console' : illegal use of type 'void'
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(10) : error C2086: 'int Console' : redefinition
        d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(3) : see declaration of 'Console'
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(11) : error C2065: 'ConsoleLine' : undeclared identifier
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(11) : error C2228: left of '.size' must have class/struct/union type
        type is ''unknown-type''
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(11) : error C2065: 'CONSOLE_LINES' : undeclared identifier
d:\Documents\CPP\Visual Studio Projects\TileSystem\Console.cpp(11) : fatal error C1903: unable to recover from previous error(s); stopping compilation

Build log was saved at "file://d:\Documents\Cpp\Visual Studio Projects\TileSystem\Debug\BuildLog.htm"
TileSystem - 24 error(s), 0 warning(s)


---------------------- Done ----------------------

    Build: 0 succeeded, 1 failed, 0 skipped



Share this post


Link to post
Share on other sites
Your problem is coming from your inclusion guard. Change _CONSOLE to CONSOLE, _CONSOLE has already been defined so the contents of console.h is being ignored.

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