+ 1

Why include a header file for classname??

I have had c++ in my school... We learned simple way to only include header files like iostream, conio etc.. But here they say that WE NEED TO CREATE A SEPARATE CPP FILE FOR A CLASS AND DECLARE A HEADER FILE LIKE "IFNDEF" ETC... Help me out... Is it necessary or some other way of coding??

14th May 2019, 9:42 AM
Sanket Khadse
Sanket Khadse - avatar
4 odpowiedzi
+ 5
The same class used by other classes of the same program.
14th May 2019, 10:07 AM
Sonic
Sonic - avatar
+ 5
It's not necessary but if your classes are going to be used in multiple source code files it's standard practice to use a header with the declarations and include it where needed.
14th May 2019, 9:53 AM
Sonic
Sonic - avatar
+ 1
Do u mean same class body in multiple programs??
14th May 2019, 9:58 AM
Sanket Khadse
Sanket Khadse - avatar
+ 1
Header contains contracts, thus hides and abstracts implementation details (that is specified in the source - cpp - file). The relation between these two are include statements.
14th May 2019, 11:02 AM
Daniel Adam
Daniel Adam - avatar