About including functions in header file instead of source file . | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

About including functions in header file instead of source file .

Hi , in SL courses Ive learned how to create a header file , and include functions (void and none-void ones) . The first problem is that , I cannot use cout in the header file even if I include iostream . So I want to use none-void function and my main goal is to write my comolete code in the header file , not the source file . All I could use by now is to declare void func(); in header file and use code in source file like this : bool Myclass::func(int x){ if(x>1){ return 1; } else return 0; } Now can I use this block in the header file ? I dont know how to do it... it just occurs errors .

10th May 2021, 12:16 PM
Ali_combination
Ali_combination - avatar
3 Answers
+ 1
Martin Taylor thank you👍
10th May 2021, 1:23 PM
Ali_combination
Ali_combination - avatar
+ 1
You can create user-defined headerfile write code on normal file and save it as your headerfile name and use it but u have to use in doubles quotes not in angular bracket.
10th May 2021, 4:22 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
A.S. thanks 👍👍
10th May 2021, 4:58 PM
Ali_combination
Ali_combination - avatar