Click here to Skip to main content
15,908,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
as I was writing a code for my project ,the compiler gave me this error message
'enterDoctor' : 'static' should not be used on member functions defined at file scope
where (enterDoctor) is a public member function which I need it to be static.
I tried to upload the source code "it's not big:thumbsup:" but I didn't know how ,so I'll post the most important instruction .
in the header file 'Doctor.h'
public:<br />
static void enterDoctor(char*&,char*&,char*&,float&);

the implementation 'Doctor.cpp'
static void Doctor::enterDoctor(char*&fName,char*&lName,char*&ad,float &fee){
	cout<<"enter first name : ";cin>>fName;
	cout<<"enter last name : ";cin>>lName;
	cout<<"enter address : ";cin>>ad;
	cout<<"enter fee : ";cin>>fee;
	}

so.....what do think ????? where is the problem !!!!!
Posted

1 solution

If you are in this position, you'll probably also have a "doctor.h" containing the class declaration looking like this:
class Doctor
{
    ...
public:
    static void enterDoctor(char*&fName,char*&lName,char*&ad,float &fee);
    ...
};


Now, in your CPP file, to define the body of this function, you don't need anymore to say it is static (static at file level means a different thing than at class level).
Just declare it as
void Doctor::enterDoctor(char*&fName,char*&lName,char*&ad,float &fee)
{
 ...
}


Note that virtual member functions also have this kind of problem.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900