I am actually using 3 files, I'm just now learning how to use separate header files and cant get it to work. Here are each of my files broken into different code:
This is my main.cpp:
I copy and pasted your code into 3 files called "main.cpp", "Sally.h" and "Sally.cpp" and I am getting the same error message...
I think something is wrong with my codeblocks...
Maybe it's codeblocks but I reckon it is the directory structure and there is a disjoint between the header and the cpp files.
Even if you use VStudio which is slightly better, unless you add the files to the project properly they will be like ships passing in the night, hence the errors you're getting. It's a while since I used codeblocks but from memory you just select the files and drag/drop them into the project.
Ok well I created a new project and added a class via File>New>Class...
I looked over the class settings and checked the files are all in the same directory and unchecked virtual destructor. I then pasted all of your code and build and still got the same error.
I dont know why the header and cpp files are not reading each other it is really stopping my learning!
The code runs properly and if it is in the right locations and you have no typos in the file names and corresponding #includes then ...
One trick also with the new project is to create a new hello world project and cut/paste/edit main into that, and then create a new class. That way the system automatically (should) handle the locations.
You can test if the header is being read by just combining the .h and .cpp files together as one .h file which is sort of where we started off.
I tried the trick you suggested and it did not fix it. I then combined the files into one and it worked, I then separated them and got the error again: "Undefined reference to header::"
I uninstalled and reinstalled code blocks before I did any of this...
Thanks for all your help!! I tried the same code today and it worked. I just opened the saved project and ran it with o problems. Still confused though