Mark44 said:
I copied what you posted in post #6, with one small change (eliminated the long path on the header file), and the program worked as expected. No muss, no fuss, no gyrations.
Of course the portion with main() has to have an #include for the header file -- the header file contains declarations for the class and its methods that you are using. And of course, the implementation file needs an #include for the header file, since the implementation is providing definitions for the class methods.
In both the user of the class (with main()) and the implementation, this is all you need as declarations for the class and its methods (functions):
You really don't want that long full path you had in post #6.
Thanks for your reply
I tried. Now I do something funky, just follow what I did.
1) I created a new project and called Temp. I right click the
Header file --> ADD --> NEW Item --> Header file which I named
Temp.h. I then copy the header file from
post 6 in.
2) I then right click the
Source File --> ADD --> NEW Item --> C++. I called
Temp.cpp. I copied the
.cpp file from
post 6 in. I then closed the
Temp project.
3) I went into the folder of Temp project and copy both
Temp.h and
Temp.cpp into a new folder somewhere else. AND I
DELETED the whole Temp project folder.
4) I then create a new empty project
T1. I added the both
Temp.h and
Temp.cpp.
like you described by
ADD-->Exist file and search and add both of them. Making sure Temp.cpp has
#include "Temp.h".
5) Then I right click
Source File--> ADD --> New Item --> C++, I copied the Source file from
post 6 in. I change to
#include "Temp.h".
I ran and it failed.
Here is the snap shot of the Source.cpp that shows red wiggled line under #include "Temp.h".
Then I ran Ctrl-F5. This is the error message.
I circled on the right side that I have Temp.h in it.I double checked all 3 files and they look right.
I did these steps because as I described in post #33. There is always some strange things going on.
To verify this.
1)I DELETED T1.
2) Create a new project
T2.
3) In
T2, I ADD the Temp.h, Temp.cpp and Source.pp STRAIGHT from the folder I saved them in( the same as before). I make sure
Source.cpp has
#include "Temp.h".
4) Ran it, it works like a Champ.
You see what I did different between the two? If I copied everything into one project straight from the folder, it works. BUT, if I create a DIFFERENT project(T1) and ADD the Temp.h and Temp.cpp, then I copy the same Source.cpp in, it doesn't recognize the Temp.h.
I know this issue for a few days already, I just never bother to ask as I have asked too many questions here already. Again, thanks for your patience in keep helping me.
Thanks