Hello,
Suppose I have created a class, with two files: MyClass.h and MyClass.cpp. Then I have started a new project, and want to use the class in the project. I can easily include the MyClass.h file by just typing #include "MyClass.h" in my project.
But how should I include the .cpp file? Or maybe in this case I should create only one file for my class, MyClass.h, which would contain the declaration as well as the implementation of the class? But if the file is included several times, I will get a compiler error, I suppose, since the same functions (method of the class) will be implemented several times.
So, my question is, how do I include .cpp files in a new project?
And could anybody recommend a book or better a web page explaining all these settings (how to include files, link libraries, ...)
Thanks in advance for help,
Mikhail.
Suppose I have created a class, with two files: MyClass.h and MyClass.cpp. Then I have started a new project, and want to use the class in the project. I can easily include the MyClass.h file by just typing #include "MyClass.h" in my project.
But how should I include the .cpp file? Or maybe in this case I should create only one file for my class, MyClass.h, which would contain the declaration as well as the implementation of the class? But if the file is included several times, I will get a compiler error, I suppose, since the same functions (method of the class) will be implemented several times.
So, my question is, how do I include .cpp files in a new project?
And could anybody recommend a book or better a web page explaining all these settings (how to include files, link libraries, ...)
Thanks in advance for help,
Mikhail.