first.h:
Code:
#ifndef FIRST_H
#define FIRST_H
void first(void);
#endif // FIRST_H
second.h:
Code:
#ifndef SECOND_H
#define SECOND_H
void second(void);
#endif // SECOND_HS
main.h:
Code:
#ifndef MAIN_H
#define MAIN_H
#include "first.h"
#include "second.h"
#endif //MAIN_H
first.cpp:
Code:
#include "first.h"
#include <iostream>
void first(void)
{
std::cout << "First" << std::endl;
}
second.cpp
Code:
#include "second.h"
#include <iostream>
void second(void)
{
std::cout << "Second" << std::endl;
}
main.cpp
Code:
#include "main.h"
int main()
{
first();
second();
}
First, compile first.cpp and second.cpp.
Then compile main.cpp, passing first.o and second.o as additional arguments to the command line (read your compiler's documentation for details on how the command line input should be formatted).
That's basically it.