Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compiler not picking up changes in code

Status
Not open for further replies.

biot023

Programmer
Nov 8, 2001
403
GB
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.
 
Sussed it - kind of.
I have a couple of progressing versions of this project.
I thought that recreating the files by copying & pasting into new files in a new project would be okay, but apparently not.
In the .cpp file, I have changed the line
#include"dm_file.h"
to
#include"C:\\Program Files\\Borland\\CBuilder6\\Projects\\dm_project_folder\\dm_file.h"

This has made everything run okay.
I'd still be curious to know why my compiler seemed to remember old code (that had no asssociation with the new that I can think of).
The form's .cpp file liked the alterations just fine, just not my seperate unit.
Bizarre!
Anyone know?

Cheers,
DJL Common sense is what tells you the world is flat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top