+ 3
Do I need to include the reference of header file of class to use the class?
I want to know if I have to include the reference of my class's header file. For example: I have include a header file called myclass.h. In this class I have a class called Myclass and its reference are included in myclass.cpp. So I want to use the Myclass in program.cpp. So I have to include my header file "myclass.h" but my question is should I have to include the reference "myclass.cpp"?
3 Respostas
+ 2
Whenever you include any header file using #include preprocessor directive. Then it just copy pastes all the content of header file into the file it has been called.
So if your class has been created in "Myclass.h" then that's all you have to include in your program in which you are going to use that class
+ 2
Thanks @Martin Taylor. I wanted to know that.
+ 1
But when I don't include "Myclass.cpp"(where the work of the constructor been told) I get an error.(I have included the header file "Myclass.h").In sololearn course, they didn't included "Myclass.cpp".