Thanks for the responses, one thing though.
I'm trying to do what firedraco says (put the prototypes in a seperate .h file, the definitions in a seperate .cpp, then use them by including the .h in your main.cpp file.) I always thought in a project .cpp files linked together in such a way they were like only one big file, accessing every other .cpp files's variables, and functions.
I guess extern would work, but than if I declare an object of a class in a .cpp, for every objects and variables I have to use extern keyword if I want to access them in another cpp?
EDIT:
Okay, I tried another thing:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
// MATRIX.H
#include <GL/gl.h>
#include "unit.h"
#ifndef MATRIX_H
#define MATRIX_H
class MATRIX {
// prototypes of functions, variables
} viewMatrix;
#endif
|
1 2 3 4 5
|
// MATRIX.CPP
#include "matrix.h"
// decleration of MATRIX class functions (construktor, destructor, etc.)
|
1 2 3 4 5 6
|
// MOUSE.CPP
#include "mouse.h"
// #include "matrix.h"
// decleration of MOUSE class functions, using and modifing viewMatrix object
|
Okay, so my problem is here: If I don't include the matrix.h in mouse.cpp, I get an error msg so that viewMatrix hasn't been decleared. If I include the matrix.h, I get an error msg so that viewMatrix has been decleared multiple times. So wtf?