Is it possible to make a C++ project without our custom header files? suppose i write a class, what about not including ...h? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is it possible to make a C++ project without our custom header files? suppose i write a class, what about not including ...h?

hearder file so mandatory?

5th Mar 2018, 12:16 PM
Romesh Khun
Romesh Khun - avatar
2 Answers
0
It's actually necessary to include a header file when dealing with classes in separate files. A header file contains the constructor's definition which links to the class itself. Without it, the compiler wouldn't know where to find the class if you used it, and would return a compiler error. If you did write the class and the main program itself in the same file, which is impractical by the way if you are using several, that's the only time header files won't be needed.
5th Mar 2018, 1:06 PM
apex137
apex137 - avatar
0
thanks nik1082
10th Mar 2018, 2:33 PM
Romesh Khun
Romesh Khun - avatar