i have a problem with some code, which is distributed over different files. I have a main.cpp where the methods are called. In this main.cpp I'm including a "deklarationen.h", which declares the methods with their signatures. For example void "average(float, float&);"
The body of this method is in a "average.cpp". But when i try to compile my main.cpp i get the following error code "\main.o:main.cpp|| undefined reference to `average(float, float&)'".
All the files are in the same directory, and as I said I'm including the header file in my main.cpp .
Hint: I'm using Code::Blocks with the ming32-gpp compiler.
Am I doing something terribly wrong, or is it a compiler bug or smth?
Greetings
Code: Main.cpp
#include "deklarationen.h"
#include <iostream>
using namespace std;
int main ()
{
//body of the function
average(b,mittel);
}
Code: deklarationen.h (same folder)
#ifndef _DEKLARATIONEN_H_
#define _DEKLARATIONEN_H_
float a;
void einlesen(float &a, float &b);
void average(float, float &avg);
void quotient(float, float&);
void produkt(float b, float& quot);
float summe(float);
extern float differenz(float);
#endif /* _DEKLARATIONEN_H_ */
Code: average.cpp (still same folder)
void average(float b,float &avg)
{
avg = (a+b)/2;
}