Linked Questions
109 questions linked to/from Why have header files and .cpp files?
54 votes
4 answers
40k views
What is the point of header files in C? [duplicate]
Possible Duplicates: [C] Header per source file. In C++ why have header files and cpp files? C++ - What should go into an .h file? Is the only reason header files exist in C so a developer can quickly ...
21 votes
4 answers
28k views
Confused about the actual purpose of header files in C++ [duplicate]
Possible Duplicate: In C++ why have header files and cpp files? I don't quite get C++ header files, for two conflicting reasons: I thought the purpose of header files was in general to separate ...
12 votes
3 answers
4k views
Why do we declare and define functions separately in C++? [duplicate]
I have only just started learning C++, and I see that functions are usually declared and defined separately, for example: // Declaration void sayhi(std::string name); // Definition void sayhi(std::...
3 votes
1 answer
9k views
Where/how to put functions in a header vs C++ source file [duplicate]
Someone asked a question similar to mine here: Function declaration inside or outside the class? Why do you just declare a function inside a .h file but not the definition, and then write the whole ...
4 votes
3 answers
6k views
Are header files necessary? [duplicate]
Possible Duplicate: In C++ why have header files and cpp files? Coming from a C# background, I find header files really annoying. Are they necessary even with C++11?
2 votes
3 answers
4k views
Class implementation in a header file == bad style? [duplicate]
I was wondering if it is advisable to write a the whole class c++ in a header file ? and use include to include the class, in a similar way that java does its oop programming. Is it a bad style ? can ...
0 votes
3 answers
2k views
Why create abc.h and abc.cpp file in a c++ program? [duplicate]
Possible Duplicate: In C++ why have header files and cpp files? I was reading some KDE tutorials for creating basic plasma widgets and other QT stuff. One thing that I noticed is almost all the ...
2 votes
1 answer
4k views
Why #include<.hpp> in .cpp, not <.cpp> in .hpp? [duplicate]
I wonder why recommended way is to #include<example.hpp> in example.cpp; I don't understand, how preprocessor (which seems to be quite simple program) knows that definition of methods are in ...
0 votes
3 answers
578 views
what to put in cpp and what to h files [duplicate]
Possible Duplicate: In C++ why have header files and cpp files? C++ - What should go into an .h file? All the functions/methods which are usually defined in .cpp file can be defined inline in .h ...
0 votes
2 answers
1k views
Creating a Derived Class in C++ [duplicate]
So im trying to make a Die class and a LoadedDie class where the Die class is the base and the LoadedDie class is derived. The only difference between the 2 classes is that the roll function in the ...
1 vote
2 answers
484 views
C Head files and Source files [duplicate]
I am a student programmer learning my first language with the book "Accelerated C++." I am at at a point where the author is explaining header files and source files containing functions. In the ...
0 votes
1 answer
415 views
Include declaration but not definition in main file C++ [duplicate]
When using multiple files in C++, for example: main.cpp, definition.cpp, declaration.h // declaration.h int Myfunc(); //definition.cpp #include "declaration.h" int MyFunc() {return 5;}; //...
-1 votes
3 answers
237 views
C++ header file [duplicate]
Possible Duplicate: In C++ why have header files and cpp files? Why in C++ is there a .h and .cpp and not only one file like c# and Java ?
0 votes
1 answer
173 views
Do c++ compilers skip parts of files when compiling? [duplicate]
In C++, I've heard that you need to separate the implementation from the interface in order to reduce compile times. In this question, the answerer basically says that if you change the header then ...
0 votes
1 answer
253 views
What is the point of .cpp files if I can use header files with the same use? [duplicate]
I may be thinking/using header files the wrong way, but currently I'm using 1 .cpp file and the rest are all in header files. I have things like a screen which is an array of characters in a header ...