header file | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula gr√°tis
+ 9

header file

how can we create a header file on our own in c/c++

18th Feb 2018, 1:11 PM
Rajesh Dehury
Rajesh Dehury - avatar
10 Respostas
+ 15
E.g. class A { public: int a; A() { a=0; } }; // name this file as classA.h // in another file: #include <iostream> #include "classA.h" int main() { A obj; std::cout << obj.a; }
18th Feb 2018, 1:24 PM
Hatsy Rei
Hatsy Rei - avatar
+ 9
Yes on a computer, but, not on SL
19th Feb 2018, 6:54 PM
Manual
Manual - avatar
+ 8
notice the difference of the include syntax @hatsy posted. #include <xxxxx> searches the header file in the include-path of your project settings #include "xxxxx" searches the header file in the folder of your project
18th Feb 2018, 1:28 PM
Alex
Alex - avatar
+ 8
so i just need to save the file by the extension oh .h then i can cuse the methods of my own .h file
19th Feb 2018, 6:43 PM
Rajesh Dehury
Rajesh Dehury - avatar
+ 7
You will need to use headers and source file in a IDE. Files cannot be linked on SL Codeblocks https://www.sololearn.com/discuss/608805/?ref=app Visual studio https://www.sololearn.com/discuss/410578/?ref=app
18th Feb 2018, 2:54 PM
Manual
Manual - avatar
+ 7
ok
19th Feb 2018, 7:04 PM
Rajesh Dehury
Rajesh Dehury - avatar
+ 7
Also you need to include the header into your .cpp file(s).
19th Feb 2018, 7:05 PM
Manual
Manual - avatar
+ 6
how
19th Feb 2018, 7:06 PM
Rajesh Dehury
Rajesh Dehury - avatar
+ 5
write the code of file u want to do and save it by using .h extension after copy paste it to library file and u can access header file made by u like #include<myheader.h> Or #include"myheader.h"
18th Feb 2018, 2:12 PM
Rinky Gupta
Rinky Gupta - avatar
+ 5
#include "xxxxx.h"
19th Feb 2018, 7:07 PM
Alex
Alex - avatar