Reputation: 191
I'm getting a number of errors in my header file that i can't seem to solve. They all seem to be in the lines that use the class Tutor
type.
Here's my code:
#pragma once
#include "Pupil.h"
#include "Tutor.h"
class Class
{
char name;
int num;
Pupil** pupils;
int pupil_amount;
Tutor* tutor;
public:
Class();
Class(char, int);
~Class();
bool Add_Pupil(Pupil* p);
Pupil* Get_Pupil(int ind);
int Get_Amount()const { return pupil_amount; }//get the amount of pupils
int Get_Num()const { return num; }//get the name of the class
Tutor* Get_Tutor()const { return tutor; } //return a pointer to the tutor
void Add_Tutor(Tutor* t) { tutor = t; }//set a tutor recieved as a pointer
char Get_Name()const { return name; }
};
These are the errors:
I solved it by declaring the class "Tutor" as a friend but then my professor told me not to use friend declarations. I tried moving the function to the .cpp file with no luck.
Is there any way i can solve this without using friend?
Upvotes: 0
Views: 36
Reputation: 31312
This error happens because compiler doesn't have declaration of 'Tutor' class when compiling your 'Class'. Check that 'Tutor.h' really contains declaration of the Tutor class.
Upvotes: 1