Hallo. I have a class (call it MyClass) that has a number of functions, one of which is the following:
virtual bool set_from_file(string& fname);
And in the .cpp file I have
bool MyClass::set_from_file(string& fname)
{
// misc code here
return true;
}
This compiles fine, but now I realise I want the function MyClass::set_from_file to return void instead of a bool.
So the alterations I make are:
// in the .h file class declaration
virtual void set_from_file(string& fname);
// and in the .cpp file
void MyClass::set_from_file(string& fname)
{
// misc code here
}
My problem is that the compiler then refuses to recognise the implementation, claiming it is not a member of MyClass.
If I comment it out, however, the linker complains of an unresolved external.
I can only assume that this is the compiler being a little slow on the uptake (having said that, it's usually me...), so does anyone know a way to bodge this through?
I've tried deleting all .obj files, etc., but the problem simply persists.
In the past I've given up & copied the implementation to the class/function declaration, but this is ugly as hell.
Any & all help gratefully received,
Doug. Common sense is what tells you the world is flat.
virtual bool set_from_file(string& fname);
And in the .cpp file I have
bool MyClass::set_from_file(string& fname)
{
// misc code here
return true;
}
This compiles fine, but now I realise I want the function MyClass::set_from_file to return void instead of a bool.
So the alterations I make are:
// in the .h file class declaration
virtual void set_from_file(string& fname);
// and in the .cpp file
void MyClass::set_from_file(string& fname)
{
// misc code here
}
My problem is that the compiler then refuses to recognise the implementation, claiming it is not a member of MyClass.
If I comment it out, however, the linker complains of an unresolved external.
I can only assume that this is the compiler being a little slow on the uptake (having said that, it's usually me...), so does anyone know a way to bodge this through?
I've tried deleting all .obj files, etc., but the problem simply persists.
In the past I've given up & copied the implementation to the class/function declaration, but this is ugly as hell.
Any & all help gratefully received,
Doug. Common sense is what tells you the world is flat.