Answers for "defining function in other file"

C++
0

defining function in other file

//Your .h file..
#ifndef MY_HEADER
#define MY_HEADER
 int add(int, int);
#endif 

//main.cpp
#include "myHeader.h"

int main()
{
  int result = add(1,2);
  return 0;
}

//file that contain definition of the functions...
//.cpp
#include "myHeader.h"

int add(int a, int b)
{
 return a+b;
}
Posted by: Guest on October-25-2020

Code answers related to "defining function in other file"

Browse Popular Code Answers by Language