Thread: Multiple Files
View Single Post
Old 09-18-2005, 10:48 AM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
1) Start up your IDE.
2) Create a new project.
2b) A main cpp file is automatically created.
3) Go to: File->New->Source File.
3b) Select "OK" when dialog box asks if you would like to add this file to the current project.
4) Go to step 3 and 3b again.
5) Save them as "OurFile.hpp" and "OurFile.cpp".
6) Declare the functions in your header the way you did.
7) Define the functions in your source file and include the header obviously.
8) Include the header in main source file as well and then just use the functions.

main.cpp
Code:
#include "OurFile.hpp"
#include <iostream>

int main()
{
  Function1();
  Function2();
  return 0;
}
OurFile.hpp
Code:
#ifndef OURHEADER_H
#define OURHEADER_H

void Function1();
void Function2();

#endif //OURHEADER_H
OurFile.cpp
Code:
#include "OurFile.hpp"
#include <iostream>

void Function1()
{
  std::cout<<"Function 1"<<std::endl;
}

void Function2()
{
  std::cout<<"Function 2"<<std::endl;
}
__________________
Valmont is offline   Reply With Quote