Witam, mam problem z wywołaniem funkcji dla operatorów pezeciążonych funkcji wzorcowej macierzy. Tak wyglada klasa macierzy
#ifndef MACIERZETEMPLATE_H
#define MACIERZETEMPLATE_H
#include "Wierszetemplate.h"
#include "Kolumnytemplate.h"
#include <iosfwd>
template <class T>
class macierzetemplate
{
public:
template <class Q>
friend class wierszetemplate;
template <class Q>
friend class kolumnytemplate;
template <class Q>
friend std::ostream& operator << (std::ostream&, const macierzetemplate<T>&);
friend std::istream& operator >> (std::istream& in, const macierzetemplate<T>&);
friend std::istream& operator >> (std::istream& in, const T&);
macierzetemplate ();
macierzetemplate (int, int);
~macierzetemplate();
int M() const;
int N() const;
T& operator()(int, int) const;
operator T**() const {return tab;};
wierszetemplate<T>& operator () (int);
kolumnytemplate<T>& operator [] (int);
macierzetemplate<T>& operator = ( macierzetemplate<T>& );
macierzetemplate<T>& operator + (const macierzetemplate<T>&, const macierzetemplate<T>&);
macierzetemplate<T> transpozycja (macierzetemplate<T>&);
int m;
int n;
private:
T** tab;
};
#include <iostream>
#include "macierzetemplate.h"
using namespace std;
template <class T>
ostream& operator << (ostream& wy, const macierzetemplate<T>& x)
{
for(int i=0; i<x.m; ++i)
{
for (int j=0;j<x.n;j++)
wy<<x(i,j)<<"|";
wy<<endl;
}
return wy;
}
template <class T>
istream& operator >> (istream& in, const macierzetemplate<T>& x)
{
for(int i=0; i<x.m; ++i)
{
for (int j=0;j<x.n;j++)
in>>x(i,j);
}
return in;
}
template <class T>
istream& operator >> (istream& in, T& x)
{
return in>>x;
}
template <class T>
macierzetemplate<T>& macierzetemplate<T>::operator = ( macierzetemplate<T>& b)
{
macierzetemplate<T> a(b.m,b.n);
for (int i=0;i<a.m;i++)
for (int j=0;j<a.n;j++)
a[i][j]=b[i][j];
return a;
}
template <class T>
macierzetemplate<T>& macierzetemplate<T>::operator + (const macierzetemplate<T>& a, const macierzetemplate<T>& b)
{
if (a.m!= b.m || a.n!=b.m)
{
throw;
}
else
{
macierzetemplate<T> c(a.m,a.n);
for (int i=0;i<c.m;i++)
for (int j=0;j<c.n;j++)
c(i,j)=a(i,j)+b(i,j);
return c;
}
}
#include <iostream>
#include "src/macierzetemplate.cpp"
#include "src/wierszetemplate.cpp"
#include "src/kolumnytemplate.cpp"
#include "wierszetemplate.operatory.cpp"
#include "kolumnytemplate.operatory.cpp"
#include "macierzetemplate.operatory.cpp"
#include "macierzetemplate.h"
using namespace std;
int main()
{
macierzetemplate<float> m(6,6);
float** tab;
tab=m;
cout<<m<<endl;
macierzetemplate<float> z(6,6);
cout<<z<<endl;
macierzetemplate<float> a=m+z;
return 0;
}
wyskakuje następujący błąd
||=== Build: Debug in macierzetemplate (compiler: GNU GCC Compiler) ===|
include\macierzetemplate.h|17|warning: friend declaration 'std::istream& operator>>(std::istream&, const macierzetemplate<T>&)' declares a non-template function [-Wnon-template-friend]|
include\macierzetemplate.h|17|note: (if this is not what you intended, make sure the function template has already been declared and add <> after the function name here) |
include\macierzetemplate.h|18|warning: friend declaration 'std::istream& operator>>(std::istream&, const T&)' declares a non-template function [-Wnon-template-friend]|
include\macierzetemplate.h|29|error: 'macierzetemplate<T>& macierzetemplate<T>::operator+(const macierzetemplate<T>&, const macierzetemplate<T>&)' must take either zero or one argument|
C:\Users\EVELINA\Downloads\2014.01.07\macierzetemplate.operatory.cpp|52|error: 'macierzetemplate<T>& macierzetemplate<T>::operator+(const macierzetemplate<T>&, const macierzetemplate<T>&)' must take either zero or one argument|
C:\Users\EVELINA\Downloads\2014.01.07\main.cpp||In function 'int main()':|
C:\Users\EVELINA\Downloads\2014.01.07\main.cpp|19|error: no match for 'operator+' in 'm + z'|
C:\Users\EVELINA\Downloads\2014.01.07\main.cpp|19|note: candidates are:|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_iterator.h|335|note: template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_iterator.h|335|note: template argument deduction/substitution failed:|
C:\Users\EVELINA\Downloads\2014.01.07\main.cpp|19|note: 'macierzetemplate<float>' is not derived from 'const std::reverse_iterator<_Iterator>'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.h|2362|note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.h|2362|note: template argument deduction/substitution failed:|
C:\Users\EVELINA\Downloads\2014.01.07\main.cpp|19|note: 'macierzetemplate<float>' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.tcc|694|note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.tcc|694|note: template argument deduction/substitution failed:|
C:\Users\EVELINA\Downloads\2014.01.07\main.cpp|19|note: mismatched types 'const _CharT*' and 'macierzetemplate<float>'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.tcc|710|note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, const std::basic_string<_CharT, _Traits, _Alloc>&)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.tcc|710|note: template argument deduction/substitution failed:|
C:\Users\EVELINA\Downloads\2014.01.07\main.cpp|19|note: 'macierzetemplate<float>' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.h|2399|note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.h|2399|note: template argument deduction/substitution failed:|
C:\Users\EVELINA\Downloads\2014.01.07\main.cpp|19|note: 'macierzetemplate<float>' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.h|2415|note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, _CharT)|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\basic_string.h|2415|note: template argument deduction/substitution failed:|
C:\Users\EVELINA\Downloads\2014.01.07\main.cpp|19|note: 'macierzetemplate<float>' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'|
C:\Users\EVELINA\Downloads\2014.01.07\main.cpp|25|error: 'b' was not declared in this scope|
||=== Build failed: 4 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
Nie wiem co jest źle, bardz proszę o pomoc.