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 8532771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:47:29+00:00 2026-06-11T09:47:29+00:00

I’m wading into the world of Operator overloading. I already had some success doing

  • 0

I’m wading into the world of Operator overloading. I already had some success doing operator overloading on my Vector2 class, I’m now working on a Matrix class and am trying to write a function that will add two matrices together into one new matrix. I’m stumbling on this error though, and Googling it doesn’t get me anywhere further as people seem to have an entirely different problem but the same issue.

Here’s class declaration:

Matrix.h

#ifndef __MAGE2D_MATRIX_H
#define __MAGE2D_MATRIX_H

namespace Mage {
    template<class T>
    class Matrix {
    public:
        Matrix();
        Matrix(unsigned int, unsigned int);
        ~Matrix();

        unsigned int getColumns();
        unsigned int getRows();

        T&       operator[](unsigned int);
        const T& operator[](unsigned int) const;
        Matrix operator+(const Matrix&);
        Matrix operator-(const Matrix&);

    private:
        unsigned int rows;
        unsigned int columns;
        T*           matrix;
    };
}

#endif // __MAGE2D_MATRIX_H

And here is the offending function that isn’t working (these are lines 31 to 45 of matrix.cpp):

matrix.cpp

template<class T>
Matrix Matrix<T>::operator+(const Matrix<T>& A) {
    if ((rows == A.getRows()) && (columns == A.getColumns())) {
        Matrix<T> B = Matrix<T>(rows, columns);
        for (unsigned int i = 0; i <= rows; ++i) {
            for (unsigned int j = 0; i <= columns; ++i) {
                B[i][j] = matrix[i][j] + A[i][j];
            }
        }

        return B;
    }

    return NULL;
}

And last but not least, here are the two errors I’m getting.

1>ClCompile:
1>  matrix.cpp
1>src\matrix.cpp(32): error C2955: 'Mage::Matrix' : use of class template requires template argument list
1>          C:\Users\Jesse\documents\visual studio 2010\Projects\Mage2D\Mage2D\include\Mage2D/Math/Matrix.h(6) : see declaration of 'Mage::Matrix'
1>src\matrix.cpp(47): error C2244: 'Mage::Matrix<T>::operator +' : unable to match function definition to an existing declaration
1>          C:\Users\Jesse\documents\visual studio 2010\Projects\Mage2D\Mage2D\include\Mage2D/Math/Matrix.h(17) : see declaration of 'Mage::Matrix<T>::operator +'
1>          definition
1>          'Mage::Matrix Mage::Matrix<T>::operator +(const Mage::Matrix<T> &)'
1>          existing declarations
1>          'Mage::Matrix<T> Mage::Matrix<T>::operator +(const Mage::Matrix<T> &)'
1>
1>Build FAILED.

Anyone have an idea what’s going on here? It’s probably really simple and I’m being daft. I need some coffee 😐

Sincerely,

Jesse

  • 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-11T09:47:30+00:00Added an answer on June 11, 2026 at 9:47 am

    ‘Mage::Matrix’ : use of class template requires template argument list

    In the definition of operator+:

     template<class T>
     Matrix<T> Matrix<T>::operator+(const Matrix<T>& A)
            ^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I am doing a simple coin flipping experiment for class that involves flipping a
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from

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.