Passing a pointer from a class to function

I am writting a word Ladder game. I think I'm done with my code, I already split it up and I was trying to print out a mock solution. Basically what it is is you give it two words, a destination and a origin. The program will convert the origin word to the destination word by only changing one letter at the time and referencing a word bank to check for real words. I think everything is fine in my code, but for some reason I get about 21 errors. This is the part on the bottom of my code and the part that I believe is failing. (Header.h; retrieve all possible words parameters)


Header.h
1
2
3
4
5
6
7
class wordLadder
{
public:
	wordLadder();
	void print();
	void searchAllPossibleWords(string word, string dest);
	void retrieveAllPossibleWords(string word, string dest, vertex *V); // here 


and this is where I pass it on the implementation...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void wordLadder::searchAllPossibleWords(string word, string dest)
{
	origWord = word;
	vertex * V = new vertex;
	V->word = word;

	for (int i = 0; i < 4; i++)
	{
		V->word[i] = '*';
		retrieveAllPossibleWords(V->word,dest, V); //here
		V->word = word;
		cout << endl;
	}

}


and

1
2

void wordLadder::retrieveAllPossibleWords(string word, string dest, vertex *V) //here  


is this how you pass a Pointer? I tried many differen combinations (With the 'address of' operator aswell... any help will be appreciated. Thanks!!!
Please copy and paste the exact first error message and indicate which line it occurs on. It may not even be relevant to the code you have shown.
@LB It's 21 Errors in total, the first one reads...

Error 1 error C2061: syntax error : identifier 'vertex'

and it's on line 7 of the Header.h file.
What is vertex? Is it a class you defined? Did you include the header for it?
@LB yeah it's a class I defined, but now that I look at it, I may be asking for infinite space in memory...

vertex.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef VERTEX_H
#define VERTEX_H

#include <string>
#include <iostream>
using namespace std;

class edge;

class vertex
{
public:
	vertex();
	string word;
	edge * wildCard[4];
};


#endif VERTEX_H 


edge.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#ifndef EDGE_H
#define EDGE_H

#include <string>

class vertex;

class edge
{
public:
	edge();
	vertex * previousVertex;
	vertex * vWords[26];
};


#endif EDGE_H 


I defined them in terms of each other attempting to create a graph-like data structure, but I wasn't able to define them under the same header file so that's why I put them in their own header files. I wasn't thinking about the memory space at the time, but I think I may be requesting infinite memory... But I still don't think that's the reason for the compiling errors, what do you think?
@LB Yeah I don't think that's the problem since I'm using pointers to I'm basically not requesting infinite memory.
Did you #include "vertex.h" in the header from your first post?
Topic archived. No new replies allowed.