Hi All,
I have created a class person and derived patient and doctor classes from person. Also I derived student_patient and emp_patient classes from patient class. I want to make a small calculation at patient, student_patient and emp_patient classes by using a function from doctor class wihch is get_fee_of_doc. I call get_fee_of_doc at other classes but I get errorC2352 . I tried to find the solution on the internet but I could not.
Can you please help me about this problem?
I appreciate for helps

Here declaration of classes:

class Patient: public Person
{
public:
	Patient();
	Patient(string name_of_patient, int age_of_patient, string address_of_pat, double visit_duration, string ssn_of_patient);
	Patient(const Patient &p);
	~Patient();
	double get_visit_duration() const;
	string get_ssn() const;
	void set_ssn_(string ssn_ofp);
	void set_visit_duration(double visit_duration_ofp);
	virtual double billing() const;
	void input(istream &inpa);
	void output(ostream &outpa);
protected:
	double visit_duration;
	string ssn;
};
class Doctor: public Person
{
public:
	Doctor();
	Doctor(string name_of_doctor, double hour_fee_of_doc, long reg_number, string specialty);
	Doctor(const Doctor &d);
	~Doctor();
	double get_fee_of_doc() const;
	long get_regnum_of_doc() const;
	string get_spec_of_doc() const;
	void set_spec_of_doc(string specialty);
	void set_fee_of_doc(double hour_fee);
	void set_regnum_of_doc(long reg_num);
protected:
	double doctor_hour_fee;
	long doctor_reg_num;
	string spacialty;
};
class Student_Patient: public Patient
{
	Student_Patient();
	Student_Patient(string name_of_student, int age_of_student, string address_of_student, double visit_of_stud, string ssn_of_student, string collage_of_student);
	Student_Patient(const Student_Patient &s);
	~Student_Patient();
	string get_collage_of_stud() const;	
	void set_collage_of_student(string collage_ofs);	
	virtual double billing() const;
	void input(istream &ins);
	void output(ostream &outs);
protected:
	string collage;
	
};
class Emp_Patient: public Patient
{
	Emp_Patient();
	Emp_Patient(string name_of_emp, int age_of_emp, string address_of_emp, double visit_of_emp, string ssn_of_emp, string department_of_emp);
	~Emp_Patient();
	string get_dep_of_emp() const;
	void set_dep_of_emp(string dep_name);
	virtual double billing() const;
	void input(istream &ine);
	void output(ostream &oute);
protected:
	string department_name;
};

definition where I get error message:

double Patient::billing() const
{
	return ((Doctor::get_fee_of_doc())*get_visit_duration());
}

definition of the function which I call:

double Doctor::get_fee_of_doc() const
{
	return doctor_hour_fee;
}

>>Doctor::get_fee_of_doc
That doesn't work because get_fee_of_doc() is not a static method. How does the patient class know who his doctor is?

in Patient class you need an instance of (or better yet a pointer to an instance of) Doctor class. And in the doctor class I presume you will want a list or vector of patient classes.

Thank you very much for your explanation but I did not understand exactly. By the way I assume that there is only one doctor and fee will be entered by input function. I just want to use fee of the doctor in other functions.

I made it static static double get_fee_of_doc(); but it still does not work the error message is error C2597: illegal reference to non-static member 'Doctor::doctor_hour_fee'.Still I did not figure out how to pass fee to other functions.
Do you have any idea?

I made it static static double get_fee_of_doc(); but it still does not work the error message is error C2597: illegal reference to non-static member 'Doctor::doctor_hour_fee'.Still I did not figure out how to pass fee to other functions.
Do you have any idea?

Because doctor_hour_fee is not static. And if you declare a member variable static you must initialize it in a .cpp file before using it.

Because doctor_hour_fee is not static. And if you declare a member variable static you must initialize it in a .cpp file before using it.

This is a function, not a data object.

And you are right about static. Put the static keyword in the class declaration, not in the implementation code.

class Doctor
{
public:
    static float get_fee_of_doc();
};
This article has been dead for over six months. Start a new discussion instead.