-
C++ help needed.
I’m teaching myself C++ and I don't have a strong knowledge in C++ so please understand that I will ask you VERY basic question. So, consider me as a beginner in C++ if you will. I am taking a class and need help with the following error message.
When creating a class, the convention seems to be to put the class declaration in a header file and put the member functions in a .cpp file. That part I do not understand.
-
I believe this is because when including header files, the #include statement simply gets replaced with the contents of the header files, meaning including definitions in a header file will get declared repeatedly and cause compiler errors.
However the definition must be somewhere, else you will also get errors for undefined functions, so they are dumped in a .cpp file, all of the .cpp files are compiled individually to .obj files and then linked together, so the functions are not defined more than once.
I could be wrong, though, so you're best to wait for somebody with more knowledge to reply...
-
That's not an error message?
-
fatal error C1083: Cannot open include file: 'reservationRecord.h': No such file or directory
Yes, I understand that I have to move your header file to the same directory your main source code is located. I know what the header file is but what i don't know is the directory file. will you please explain to me in more detail how I would know the directory it belongs in. can anyone give me an example of what this is saying?
-
Where is the file? Where is it compared to the rest of your files? Did you add it to your project? If you don't understand how your filesystem works, how can you expect to be a programmer?
-
That is correct. I don't understand how the filesystem works. can you explain it?
-
-
I am looking for help in every place I can. Can you help me?
-
when you said file system is this what your talking about?
Code:
function
prototypes
function #1
function #2
function #3
#include <iostream>
using namespace std;
void simon(int);
double taxes(double);
int main()
{
...
return 0;
}
void simon(int n)
{
...
}
double taxes(double t)
{
...
return 2 * t;
}
-
Can you help me with my problem?
-
Don't teach yourself C++. Teach yourself computers first. You need some technical knowledge of how computers work in order to be an effective programmer, especially in C++.
-
This is the answer I was looking for.
It just means that your header file can’t be found. If you put it in the same directory as your cpp file, it should be fine. If you are using Visual Studio, open your project, and open your code file (the cpp file). Then go to the file menu and do a Save As on your CPP file and it will show you the directory where it is saved. Then just be sure to save your .h header file into the same path.
-
Basic filesystem workings. That's why they told you to learn computers first.