cant find silly mistake

Ok, so I'm obviously making some stupid mistake, but I've been trying to find it for 20 minutes so...

Here is my class declaration file "game.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
27
  //class Game declaration file
#ifndef GAME_H
#define GAME_H
#include "bead.h"
#include "player.h"
#include <vector>
using namespace std;
class Game {
private:
	char userInput;
	vector<Bead> beads;
	int boardWidth;
	int boardHeight;
	Bead* beadPtr;
	int cursorXPos;
	int cursorYPos;
public:
	Game();
	void render(); 
	bool isOver(Player p);
	void takeUserInput();
	void makeBeads();
	void deleteBeads();
	void movePlayer();
	void updateGame();
};
#endif 

You'll notice I have declared the char userInput.

In my game.cpp file, I wrote the following function:
1
2
3
void takeUserInput() {
	userInput = getch();
}


I have included "game.h" in game.cpp, but for some reason I am getting the "use of undeclared identifier" error.

What am I doing wrong?

Thanks!
1
2
3
void Game::takeUserInput() {
  ...
}

I presume you have <conio.h> included somewhere also?

Hope this helps. :)
Yup, super silly mistake! Thanks for catching it! I am actually using ncurses. Is there an advantage to conio, or is it the same?
conio.h is non-standard so I wouldn't assume there be any advantages also according to microsoft you should use _getch() instead of getch() as it is deprecated.
"Deprecated" according to Microsoft. It's still part of the old (ancient) MS DOS terminal functions. That particular function lives on for its simple utility, and I assumed (incorrectly) that you were using the <conio.h> library. Sorry.

[edit] That is, there is a commonly-known function with the same name... Most people won't think of NCurses's getch() first...[/edit]

NCurses is superior, so keep using it. (Good job!)
Last edited on
Thank you Duoas and giblit!
Topic archived. No new replies allowed.