Followers 0

# Header function not being recognized

## 7 posts in this topic

Hello,

I have a Matrix4x4 template class in a header file. I've read that templates need to be only in headers (source: http://stackoverflow.com/questions/495021/why-can-templates-only-be-implemented-in-the-header-file). Now, my problem is that when I change my header's code by adding a function and that I use this method somewhere (in main() in my case), then the compiler tells me my class Matrix4x4 doesn't contain the function. I thought that doing a rebuild would correct this error, but it doesn't work. Do you have any idea what I could do to fix this error?

Thank you,

Thecheeselover

0

##### Share on other sites

Exemple:

namespace UCC
{
template <class T>
class Matrix4x4
{

public:

T m11, m12, m13, m14;
T m21, m22, m23, m24;
T m31, m32, m33, m34;
T m41, m42, m43, m44;

Matrix4x4()
{
m11 = 1;
m12 = 0;
m13 = 0;
m14 = 0;

m21 = 0;
m22 = 1;
m23 = 0;
m24 = 0;

m31 = 0;
m32 = 0;
m33 = 1;
m34 = 0;

m41 = 0;
m42 = 0;
m43 = 0;
m44 = 1;
}

void SetIdentity()// not recognized
{
m11 = 1;
m12 = 0;
m13 = 0;
m14 = 0;

m21 = 0;
m22 = 1;
m23 = 0;
m24 = 0;

m31 = 0;
m32 = 0;
m33 = 1;
m34 = 0;

m41 = 0;
m42 = 0;
m43 = 0;
m44 = 1;
}
static Matrix4x4 GetIdentity_S() // not recognized, don't know if there's an error here, I was testing when it didn't work
{
return Matrix4x4<T>();
}
}
}



My main.cpp:

#include "Math/Matrix4x4.h"

using namespace UCC;

int main()
{
Matrix4x4<float> matrix;
matrix.SetIdentity(); // error: 'class UCC::Matrix4x4<float>' has no member named 'SetIdentity'|

return EXIT_SUCCESS;
}


0

##### Share on other sites

Are you sure that "#include "Math/Matrix4x4.h"" is actually including that file? The reason I ask is because it contains a compile-time error. Perhaps you're editing one file but another is being included?

1

##### Share on other sites

Ignore me....

Edited by RobTheBloke
0

##### Share on other sites

Are you sure that "#include "Math/Matrix4x4.h"" is actually including that file? The reason I ask is because it contains a compile-time error. Perhaps you're editing one file but another is being included?

I checked if it was included by changing ''matrix.SetIdentity();'' to ''matrix.Transpose();'', which is another function in Matrix4x4.h, and it worked.

Ignore me....

???

0

##### Share on other sites

Are you sure that "#include "Math/Matrix4x4.h"" is actually including that file? The reason I ask is because it contains a compile-time error. Perhaps you're editing one file but another is being included?

You were right. I finally found the bug: the Matrix4x4 I was including wasn't the good one. The thing is I had the same Matrix4x4 class in another project and my current project still had dependencies to the old one. Thank you :)

0

Thanks!

0

## Create an account

Register a new account