Jump to content
  • Advertisement
Sign in to follow this  
thecheeselover

Header function not being recognized

This topic is 1858 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement

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;
}

Share this post


Link to post
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?

Share this post


Link to post
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....

???

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!