Let's say I have the following program called test.cpp:
Code:
#include <iostream>
#include "my_header.h"
using namespace std;
void swap(int &a, int &b);
int main()
{
int a, b;
a = 1;
b = 2;
swap( a, b);
cout <<"After calling swap:"<< endl;
cout << "a = " << a << endl;
cout << "b = " << b << endl;
return 0;
}
It calls a function called swap, which is defined in the file my_header.h.
This is all dandy, but the file my_header.h defines another function called square. This is shown below:
Code:
void swap(int &a, int &b)
{
int temp;
temp = a;
a = b;
b = temp;
}
void square(int &a, int &b)
{
int temp;
square_var(a, b, temp);
}
The function square calls another function, square_var, which is defined in a header file called my_other_header.h. Let's say that I want to compile the main program on my friends computer. Is there a way I can modify my_header.h so that my friend can compile test.cpp on his computer with out having to have the file my_other_header.h??