C++ templates - matrix class

Posted by lastOfMohicans on Stack Overflow See other posts from Stack Overflow or by lastOfMohicans
Published on 2011-02-06T15:19:38Z Indexed on 2011/02/06 15:25 UTC
Read the original article Hit count: 558

Filed under:
|

Hi I'm learning templates in C++ so I decied to write matrix class which would be a template class. In Matrix.h file I wrote

 #pragma once
#include "stdafx.h"
#include <vector>



using namespace  std;

template<class T>
class Matrix
{
public:

    Matrix();

    ~Matrix();
    GetDataVector();
    SetDataVector(vector<vector<T>> dataVector);
    bool operator == (Matrix* matrix);
    bool operator < (Matrix* matrix);
    bool operator <= (Matrix* matrix);
    bool operator > (Matrix* matrix);
    bool operator >= (Matrix* matrix);
    Matrix* operator + (Matrix* matrix);
    Matrix* operator - (Matrix* matrix);
    Matrix* operator * (Matrix* matrix);

private:
    vector<vector<T>>  datavector;
    int columns,rows;


};

In Matrix cpp Visual Stuio automaticlly generated code for default constructors

#include "StdAfx.h"
#include "Matrix.h"


Matrix::Matrix()
{
}



Matrix::~Matrix()
{
}

However if I want to compile this I get an error

'Matrix' : use of class template requires template argument list The error are in file Matrix.cpp in default constructors What may be the problem ??

© Stack Overflow or respective owner

Related posts about c++

Related posts about templates