I have three .cpp files these are named MeshLoader.cpp, DynamicXMesh.cpp and StaticXMesh.cpp
I have a function in the MeshLoader.cpp file named FindTexturePath and I want to call and use it in the DynamicXMesh.cpp and StaticXMesh.cpp files.
I have included MeshLoader.cpp(#include “MeshLoader.cpp”) file in boot XMesh files and of course get an error that says function is already defined…
Also I tryed to use pragma once and ifndef …:
//This is "MeshLoader.cpp"
pragma once
#ifndef MLOAD
#define MLOAD
char* FindTexturePath( char* TexturePath ,LPSTR FileNameToCombine){
...
...
...
}
#endif
/////
//This is StaticXMesh.cpp
#include "MeshLoader.cpp"
...
...
...
this->StatXMeshTexturePath = FindTexturePath(StatXMeshTexturePath,d3dxMaterials[i].pTextureFilename);
...
...
/////
And same call for DynamicXMesh.cpp
I hope I explained myself clear enough… Thank you for givin your time…
You need to create MeshLoader.h, and put something like this in it
And include that in your other cpp files. Each of the cpp files just need the declaration of FindTexturePath to compile. So whenever you need to make a function in a cpp public to other cpp files, create a .h file that has the function declarations in.