Visual Studio 2010 error C3861: identifier not found

So I'm a Java programmer that's learning C++, and I decided to write a basic RPG-type game to teach myself about headers, pointers, libraries, etc. The methods below are meant to build an array of Equipment objects from all the files in the directory /data/equp. When I try to build the file, though, I get the error "Visual Studio 2010 error C3861: 'readEquipment' identifier not found" at line 23 below. I'm still a little fuzzy on when to use a pointer rather than an object, is that the problem?

Any bonus help regarding the actual process of reading the files in a directory is welcome as well. I have a feeling this will have any number of runtime or syntax errors after it finally compiles.

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
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>

#include "Windows.h"
#include "Character.h"
#include "Equipment.h"

using namespace std;

bool buildEquipment(Equipment* eqArr){
	WIN32_FIND_DATA findData;
	LPCSTR find = "./data/equp/*";
	HANDLE dir;
	int count = 0;

	dir = FindFirstFile(find, &findData);

	if (dir != INVALID_HANDLE_VALUE){
		do{
                        //ERROR LINE
			eqArr[count] = readEquipment(findData);
			count++;
		}while(FindNextFile(dir, &findData));
	}
	
	return true;
}

Equipment readEquipment(WIN32_FIND_DATA findData){
	ifstream myfile;
	myfile.open(findData.cFileName);
	string hold;
	Equipment eq;
		
	if(myfile.is_open()){
		//assign values from myFile to eq
	}
	myfile.close();
	return eq;
		
}

You need to prototype your method.

Add the following before any function definition:

 
Equipment readEquipment(WIN32_FIND_DATA findData);


Or you can put hte readEquipment() function before buildEquipment but eventually you may run into a circular dependency in which case only funciton prototyping can save you.
Thanks, that worked. I've been spoiled by Java classes always being aware of its fellow functions.
No problem. This is one of the annoying things of C/C++. Java got it done right!
C++ classes are also aware of their fellow functions. But you aren't using classes....

EDIT: or maybe you meant to be but didn't by mistake? Those functions you pasted are global .. not part of a class.
Last edited on
They were meant to be global, I'm again just used to putting everything in a class with Java, and haven't shaken the habit of calling every source file a class.
Topic archived. No new replies allowed.