Problem with std

I'm trying to make a game in SDL and have started working on the menus. My problem is that I have an std::string declared in a class, and I get an error about it being undeclared. In another class, I have an std::vector declared and when I use it I get an error saying that it's undeclared. It's probably a simple mistake. Sorry for all of the code.

Here's "Menu.h":
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef MENU_H
#define MENU_H

#include <string>
#include <sstream>
#include "SDL.h"
#include "SDL_ttf.h"

class Menu
{
	Uint8 menuAlpha;
	SDL_Color color;
	std::string menuText;
	int xPos;
	int yPos;
public:
	Menu();
	~Menu();
	void setAlpha(Uint8 alpha);
	void setPosition(int x, int y);
	void setText();
	void render();
	void update();
};

#endif 


Menu.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "Menu.h"

Menu::Menu()
{
	color.r = 255;
	color.g = 255;
	color.b = 255;
}

Menu::~Menu()
{
}


void Menu::setAlpha(Uint8 alpha)
{
	menuAlpha = alpha;
}

void Menu::setPosition(int x, int y)
{
	xPos = x;
	xPos = y;
}

void setText(std::string text)
{
	menuText = text;
}

void Menu::render()
{
	TTF_Init();
	TTF_Font *font;
	font = TTF_OpenFont("georgia.ttf", 16);
	std::stringstream temp;
	temp << menuText;
	SDL_Rect coordinates;
	coordinates.x = xPos;
	coordinates.y = yPos;
	SDL_Surface *message = NULL;
	message = TTF_RenderText_Solid(font, temp.str().c_str(), color);
	SDL_SetAlpha(message, SDL_SRCALPHA, menuAlpha); 
	SDL_BlitSurface(message, NULL, SDL_GetVideoSurface(), &coordinates);
	TTF_CloseFont(font);
	TTF_Quit();
	SDL_FreeSurface(message);
}


MenuSystem.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef MENU_SYSTEM_H
#define MENU_SYSTEM_H


#include <vector>
#include "SDL.h"
#include "Menu.h"

class MenuSystem
{
	std::vector<Menu *> menus;
	int currentMenu;
	SDL_Event event;
public:
	MenuSystem();
	~MenuSystem();
	void add();
	void update();
	void render();
};

#endif 


MenuSystem.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "MenuSystem.h"

MenuSystem::MenuSystem()
{
}

MenuSystem::~MenuSystem()
{
}

void add(Menu menu)
{
	menus.push_back(menu);
}

void MenuSystem::update()
{
	SDL_PollEvent(&event);
	if (event.type == SDL_KEYDOWN)
	{
		if (event.key.keysym.sym == SDLK_UP)
		{
			currentMenu++;
		}
		else if (event.key.keysym.sym == SDLK_DOWN)
		{
			currentMenu--;
		}
	}
}

void MenuSystem::render()
{
	Menu *temp = menus.at(currentMenu);
	temp->render();
}


Here's the errors I get:
c:\documents and settings\*****\desktop\pickin' sticks clone\pickin' sticks clone\menu.cpp(28) : error C2065: 'menuText' : undeclared identifier
MenuSystem.cpp
c:\documents and settings\*****\desktop\pickin' sticks clone\pickin' sticks clone\menusystem.cpp(13) : error C2065: 'menus' : undeclared identifier
c:\documents and settings\*****\desktop\pickin' sticks clone\pickin' sticks clone\menusystem.cpp(13) : error C2228: left of '.push_back' must have class/struct/union
type is ''unknown-type''
setText/add are missing the ClassName:: in front of them.
I knew it would be something simple. Why didn't I see that?
Don't know about those but this is wrong. menus is a vector that contains menu pointers not menu objects.
1
2
3
4
void add(Menu menu)
{
	menus.push_back(menu);
}
Why didn't I see that? I should get my vision checked. Thanks for your help.
Topic archived. No new replies allowed.