-
Help!
Hi guys.
I have a problem here. Hope that some can help me out.
I define 2 classes: Professor and Course.
Course.h
Code:
#ifndef COURSE_H
#define COURSE_H
#include <iostream>
#include <string>
#include <sstream>
#include <boost/xpressive/xpressive.hpp>
#include "Professor.h"
using namespace std;
using namespace boost::xpressive;
class Professor;
class Course{
public:
Course();
Course(string courseCode,string courseName,int modularCredits,Professor newProfessor);
void setProfessor(Professor professor);
protected:
Professor theProfessor();
string courseCode;
string courseName;
int modularCredits;
};
#endif
Course.cpp
Code:
#include <iostream>
#include <string>
#include <boost/xpressive/xpressive.hpp>
#include <sstream>
#include "Course.h"
#include "Professor.h"
using namespace std;
using namespace boost::xpressive;
Professor tmp;
Course::Course(string courseCode,string courseName,int modularCredits,Professor newProfessor)
{
setCourseCode(courseCode);
setCourseName(courseName);
setModularCredits(modularCredits);
setProfessor(newProfessor);
}
void Course::setProfessor(Professor newProfessor)
{
tmp.setName(newProfessor.getName());
tmp.setGender(newProfessor.getGender());
tmp.setIC(newProfessor.getIC());
string line;
line=tmp.getName();
theProfessor.setName(line);
line=tmp.getIC();
theProfessor.setIC(line);
line=tmp.getGender();
theProfessor.setGender(line);
}
Professor.h
Code:
#ifndef PROFESSOR_H
#define PROFESSOR_H
#include <iostream>
#include <string>
#include <boost/xpressive/xpressive.hpp>
#include "Person.h"
#include "Course.h"
using namespace std;
using namespace boost::xpressive;
class Course;
class Professor:public Person{
public:
Professor();
Professor(string name,string ic, string gender);
static int lastAssignedID;
protected:
int staffID;
vector<Course> teachingCourse;
//vector<string> teachingCourses;
};
#endif
Professor.cpp
Code:
#include <iostream>
#include <string>
#include <conio.h>
#include <vector>
#include "Professor.h"
//#include "Course.h"
using namespace std;
int Professor::lastAssignedID=0;
Professor::Professor():Person()
{}
Professor::Professor(string name, string ic, string gender): Person(name,ic,gender)
{
staffID=lastAssignedID;
lastAssignedID+=1;
}
int Professor::getStaffID(){
return staffID;
}
When I compile, the error is "insufficient contextual information to determine type".
How can it be solved?
Thank you.
-
Presumably "insufficient contextual information to determine type" is attached to some particular statement?
-
Oh Yes.It attached to theProfessor.setName(line),theProfessor.setGender( line) and theProfessor.getIC(line).
-
That's an interesting error message -- is theProfessor declared anywhere? I don't see it. If you intend to use the newProfessor object passed in, you should do so. (And also, if you intend to modify the newProfessor object that was passed in, you need to pass it in by reference, as in Professor &newProfessor.)
-
-
>>Professor theProfessor();
This declares a function return a Professor that is named theProfessor. Probably not what you want.