Problems with declarations

Hello everyone. I'm writing a program that uses a binary tree to hold student info such as GPA, name and ID number, Problem is I've run into some issues with declarations and could use some help.

Main.ccp
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
#include <iostream>
#include "Student.h"
#include "BinaryTree.h"
using namespace std;
int main()
{
	int num = 0;
   EmployeeInfo item;
    BinaryTree<StudentInfo> tree;
    
   
    cout << "Inserting nodes. ";
    item.setID(2142);
    item.setName("William Irving");
    item.setGPA (3.41);
    BinaryTree<EmployeeInfo>::TreeNode node;
    node.value = item;
    tree.insertNode(item);
    
 
    
    
    
	// Display the Student List.
	cout << "Here are the Students:\n\n";
	tree.displayInOrder();
	// Get an ID number to search for.
	cout << "\nEnter the Student's number: ";
	cin >> num;
	// Search for the Student in the tree.
	EmployeeInfo *ptr = tree.searchNode(num);
	if (ptr)
	{
		cout << "Student was found:\n" << *ptr;
	}
	else
	{
		cout << "That Student was not found.\n\n";
	}
	system ("pause");
	return 0;
}


Student.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/////////////////////////////
// StudentInfo class
/////////////////////////////
#ifndef STUDENT_H
#define STUDENT_H
#include <iostream>
#include <string>
#include "BinaryTree.h"
using namespace std;
// Forward declaration of the Student class.
class StudentInfo;
ostream &operator << (ostream &, StudentInfo &);
class StudentInfo
{
private:
		int stuID;
		string name;
		double gpa;

public:
	friend class BinaryTree<StudentInfo>;
	StudentInfo(int id = 0, char* n = "None" )
	{
		stuID = id;
		name = n;
		gpa = g
	}
	void setID(int n)
	{
		stuID = n;
	}
	void set GPA(double g)
	{
         gpa = g
    }
	void setName(char *str)
	{
		name = str;
	}
	void setName(string str)
	{
		name = str;
	}
	int getID()
	{
		return this->stuID;
	}
	bool operator==(int value)
	{
		return this->getID() == value;
	}
	string getName()
	{
		return name;
	}
	bool operator==(const StudentInfo& stu)
	{
		return this->stuID == stu.stuID;
	}
	bool operator< (const StudentInfo& stu)
	{
		return this->stuID < stu.stuID;
	}
	bool operator> (const StudentInfo& stu)
	{
		return this->stuID > stu.stuID;
	}
	friend ostream &operator<<(ostream &strm, StudentInfo &obj)
	{
		strm << "ID Number: " << obj.stuID << "\tName: " << obj.name << "GPA: " << obj.gpa << endl;
		return strm;
	}
};
#endif 


I believe the issue lies in my Student.h but I can't seem to put a pin in what went wrong.
Edit: I'm using a binary tree header as well, but haven't included in due to length. I can provide it if necessary, but I tested it with another program and it seems to work fine.



Last edited on
What "issues"?
on line 21 you trying to use the incomplete type StudentInfo
why do you want to make BinaryTree a friend?

on line 12/68: the operator is defined as both friend and not friend
Topic archived. No new replies allowed.