Fishery

Catch many information here

  • It is possible to create /design a header file in c++.  Just declare your prototype functions in a c++ file.
    For example:
    #define RES_32
    Void masters(){
    ….. your functions
    }
    You save this file as an “.h” extension, and include it within your program. Then you use all the functions in your c++ course file/program.
    You can create header files in c/c++. The only thing you have to do is write your program without main() and store this program with extension “.h”. It is the best if you store it in the folder which contains all the header files. We can have header files like this and use them as we use other header files.
    The way to write header files is:
    functions.h:
    int sum( int a, int b);
    functions.cpp:
    #include “functions.h”
    int sum(int a, int b){
    return a+b;
    }
    Compile:
    g++ -c functions.cpp –o functions.o
    main.cpp:
    #include”functions.h”
    main() {
    cout<<sum(1,2)<<endl;
    }
    Compile and execute main:
    g++ main.cpp functions.o –o main
    main

    No Comments