+ 3
How can we create our own library just like iostream?
4 Answers
+ 5
Yes, thats the convention.
To store the declarations separately, you create a seperate C++ file with the same name as the header and write the definitions in it. Don't use main even here. Do include the header created before, like you will do in the normal main program.
And yes, don't include this C++ file in your main program.
+ 4
Steps : Windows.
0) Windows+R.
1) Type 'notepad' inside the box.
2) When the untitled file opens, Save it with a name but change the extension to .h instead of .txt
3) Write your code inside the header. Do not add main. Just add function definitions, constant declarations, classes, etc.
4) Use the functions inside any C++ file in the same location, by adding this : #include"name_of_file.h".
// Replace the name_of_file with any name.
+ 2
Thanks @KinshukVasist. But according to conventions, only declaration should be in the header file and its definition should be in the implementation file. So, how do I do that?
+ 1
Thanks a lot @KinshukVasist