Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8014103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:49:43+00:00 2026-06-04T19:49:43+00:00

First of all, a snippet of my code in matrix.hpp : template <class T>

  • 0

First of all, a snippet of my code in matrix.hpp:

template <class T>
class matrix
{
  public:
    matrix();

    T& operator() (size_t i, size_t j) {return elem[i+j*4];}
    const T& operator() (size_t i, size_t j) const {return elem[i+j*4];}

    // ...

    static matrix<T> identity() {return matrix<T>();}
    static matrix<T> translation(const vector<T>&);
    template <class RT> static matrix<T> rotation_x(RT);

    // ...

};

// ...

template <class T>
inline
matrix<T>
matrix<T>::translation(const vector<T>& v)
{
    matrix<T> result;
    result(0, 3) = v.x;
    result(1, 3) = v.y;
    result(2, 3) = v.z;
    return result;
}

template <class T, class RT>
inline
matrix<T>
matrix<T>::rotation_x(RT angle)
{
    RT ca = std::cos(angle);
    RT sa = std::sin(angle);
    matrix<T> result;
    result(1, 1) = +ca;
    result(1, 2) = -sa;
    result(2, 1) = +sa;
    result(2, 2) = +ca;
    return result;
}

As far as I can tell, those two implementations don’t differ much technically. The main difference is that rotation uses an extra template argument compared to translation

Yet, g++ doesn’t accept rotation the way I currently have it:

la/matrix.hpp:272:31: error: invalid use of incomplete type 'class la::matrix<T>'
la/matrix.hpp:16:7: error: declaration of 'class la::matrix<T>'

What’s going on here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T19:49:44+00:00Added an answer on June 4, 2026 at 7:49 pm

    Your class only had one template parameter, and the second one refers to a template function of a template class, so you need

    template <class T>
    template <class RT>
    inline
    matrix<T> matrix<T>::rotation_x(RT angle) { .... }
    

    This applies whether the functions are static or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following short code snippet. namespace B { public class Foo { public
First of all, here is my code snippet: var str = '<!--:de-->some german text<!--:--><!--:en-->some
Hi all first post here :) Let's start with a snippet of the code
First of all I want to mention two things, One: My code isn't perfect
I have the following code snippet: // Initialise rectangular matrix with [][] instead of
The following code snippet I have is a function that accepts a rectangular matrix
I am following this guide I added the first snippet of code to my
In the following snippet of code, I've overloaded the operator== to compare my pair
Hey I am trying to understand the following code snippet. public static void main(String[]
TO CLARIFY: I can't even compile due to messages from Eclipse. First code snippet:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.