#include<iostre am>
using namespace std;
class teacher;
class student
{
int dept;
public:
student(int d)
{
dept=d;
}
bool TsameDept (teacher tch)
{
if (dept==tch.getD ept())
return true;
else
return false;
}
};
class teacher
{
int dept;
public:
teacher(int d)
{
dept=d;
}
int getDept()
{
return dept;
}
};
void main()
{
student st(5);
teacher tch(5);
if (st.TsameDept(t ch)==true)
cout<<"Same";
else cout<<"Differen t";
}
can anybody pls help
why this program shows compile error------use of undefined type 'teacher' or left of '.getDept' must have class/struct/union type
though I forward declared the teacher class.
using namespace std;
class teacher;
class student
{
int dept;
public:
student(int d)
{
dept=d;
}
bool TsameDept (teacher tch)
{
if (dept==tch.getD ept())
return true;
else
return false;
}
};
class teacher
{
int dept;
public:
teacher(int d)
{
dept=d;
}
int getDept()
{
return dept;
}
};
void main()
{
student st(5);
teacher tch(5);
if (st.TsameDept(t ch)==true)
cout<<"Same";
else cout<<"Differen t";
}
can anybody pls help
why this program shows compile error------use of undefined type 'teacher' or left of '.getDept' must have class/struct/union type
though I forward declared the teacher class.
Comment