Witam
Kompliatr wskazuje błąd przy skomentowanej linijce.
#include <iostream>
#include <string>
using namespace std;
template <class W>
class Wektor3d
{
private :
W x, y, z;
public :
Wektor3d() : x(0), y(0), z(0) { cout << " konstruktor domyślny" << endl;}
Wektor3d(W x = 1, W y = 1, W z = 1 )
{
cout << "Konstruktor merytoryczny " << endl;
this->x = x;
this->y = y;
this->z = z;
}
void wypisz() const { cout << "[" << x << ", " << y << ", " << z << "]" << endl; }
// Funkcja mnoży wektor o podana liczbe calkowita od użytkownika
void MnozCalkowita(const W &liczba);
// Funkcja mnoży podany wektor o liczbe calkowita
Wektor3d operator * (const W &liczba);
// wypisanie wektora na ekran. Działą samo jak funkcja wypisz()
friend ostream & operator << (ostream &os, const Wektor3d<W> & wek) const; // <--ZŁA deklaracje według niego
};
teplate <typename W>
ostream & operator << (ostream &os, const Wektor3d<W> & wek) const
{
os << "[" << x << ", " << y << ", " << z << "]" << endl;
return os;
}
template <typename W>
void Wektor3d<W>::MnozCalkowita(const W &liczba)
{
x = x * liczba;
y = y * liczba;
z = z * liczba;
}
/*
template <typename W>
Wektor3d Wektor3d<W>::operator * (const W &liczba)
{
x *= liczba;
y *= liczba;
z *= liczba;
return *this;
}
*/
int main()
{
Wektor3d<int>I1(1, 1, 1);
//Wektor3d<double>D1(2.69, 22.11, 23.21);
//Wektor3d<int>I2;
//I2.wypisz();
//(I1 * 10).wypisz();
cout << I1;
return 0;
}
Dziękuje bardzo z góry za pomoc.