+ 4

Why we use #include in c++ program ?

My Theory : #include is used to include header files to our program, right ?

3rd Sep 2019, 7:52 AM
Sharook Sha
Sharook Sha - avatar
9 odpowiedzi
+ 11
Common in built function like getch() clrscr() stored in <conio.h> header files. to use this function we are including <conio.h> header file and the getch() function is used to hold the output screen for a while in the sense till any key is pressed.
4th Sep 2019, 3:52 PM
Ayushi Gujarati
Ayushi Gujarati - avatar
3rd Sep 2019, 8:53 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 5
thats the main reason, which you have pointed out
3rd Sep 2019, 8:03 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 4
Maybe the question has been asked before and you could search for it.
5th Sep 2019, 2:51 AM
Sonic
Sonic - avatar
3rd Sep 2019, 10:15 AM
Kireii
Kireii - avatar
+ 3
Yup, if you don't include the header file, you can't use the class which is defined in the header file.
4th Sep 2019, 7:48 AM
Plankton
Plankton - avatar
+ 2
Correct. You're just adding the contents of another file into your current file.
3rd Sep 2019, 2:13 PM
Joe Srebernak
Joe Srebernak - avatar
+ 2
It is used to include header files of c,c++
4th Sep 2019, 2:07 PM
Prince Varshney
Prince Varshney - avatar
+ 2
The include statement actually copies the contents of the header file into the CPP file where the include statement is, during compilation. This is one of the reasons it's bad to use things like 'using std' In them as that using statement gets propagated into any CPP files that include that header.
4th Sep 2019, 4:11 PM
Thomas Brewster
Thomas Brewster - avatar