Привет всем! Программа реализации двух классов. Выдает ошибку
use of undefined type 'Vector4' . не знаю как ее исправить. можете чем помочь или подсказать?
Код:
#include<iostream>
#include<conio.h>
#include<locale.h>
using std::cout;
using std::cin;
using std::endl;
const int N = 4;
class Vector4;
class Matrix4
{
protected:
double _matrix[N][N];
public:
Matrix4 () {};
~Matrix4 () {};
friend class Vector4;
friend void Vector4::MultVectorMatrix(const Matrix4& Matrix, const Vector4& Vector);
void InputMatrix();
void OutputMatrix();
void NumberMatrix(int Number);
void MatrixVec(const Matrix4& Vector);
Matrix4 operator*(const Matrix4& Matrix)const;
Matrix4 operator+(const Matrix4& Matrix)const;
};
class Vector4
{
protected:
double _vector[N];
public:
Vector4 () {};
~Vector4 () {};
void MultVectorMatrix(const Matrix4& Matrix, const Vector4& Vector);
void InputVector();
void OutputVector();
Vector4 operator*(const Vector4& Vector)const;
Vector4 operator+(const Vector4& Vector)const;
};
//--------------------Реализация класса Matrix4-------------------
void Matrix4::InputMatrix()
{
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < N; ++j)
{
cin >> _matrix[i][j];
}
}
}
void Matrix4::OutputMatrix()
{
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < N; ++j)
{
cout << " " << _matrix[i][j];
}
cout << endl;
}
}
void Matrix4::NumberMatrix(int Number)
{
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < N; ++j)
{
_matrix[i][j] = _matrix[i][j]*Number;
cout << _matrix[i][j] << " ";
}
cout << endl;
}
}
Matrix4 Matrix4::operator +(const Matrix4& Matrix)const
{
Matrix4 ResultMatrix(*this);
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < N; ++j)
{
ResultMatrix._matrix[i][j] = this->_matrix[i][j] + Matrix._matrix[i][j];
}
}
return ResultMatrix;
}
Matrix4 Matrix4:: operator*(const Matrix4& Matrix)const
{
Matrix4 ResultMatrix(*this);
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < N; ++j)
{
ResultMatrix._matrix[i][j] = 0;
for (int k = 0; k < N; ++k)
{
ResultMatrix._matrix[i][j] += this->_matrix[i][k]*Matrix._matrix[k][j];
}
}
}
return ResultMatrix;
}
//-------------------------Реализация класса Vector4----------------------
void Vector4::InputVector()
{
for (int i = 0; i < N; ++i)
{
cin >> _vector[i];
}
}
void Vector4::OutputVector()
{
for (int i = 0; i < N; ++i)
{
cout << " " << _vector[i];
}
cout << endl;
}
Vector4 Vector4::operator +(const Vector4& Vector)const
{
Vector4 ResultVector(*this);
for (int i = 0; i < N; ++i)
{
ResultVector._vector[i] = this->_vector[i] + Vector._vector[i];
}
return ResultVector;
}
void Vector4::MultVectorMatrix(const Matrix4& Matrix, const Vector4& Vector)
{
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < N; ++j)
{
_vector[i] += Matrix._matrix[i][j]*Vector._vector[i];
}
cout << _vector[i] <<" ";
}
}
void main()
{
Matrix4 x,y,c,d;
int num;
Vector4 a,b,g;
setlocale(LC_ALL,"Russian");
cout << "Введите первую матрицу:" << endl;
x.InputMatrix();
cout << "Введите вторую матрицу:" << endl;
y.InputMatrix();
cout << "Введите первый вектор:" << endl;
a.InputVector();
cout << "Введите первый вектор:" << endl;
b.InputVector();
cout << "Первая матрица:" << endl;
x.OutputMatrix();
cout << "Вторая матрица:" << endl;
y.OutputMatrix();
cout << "Первый вектор: " << endl;
a.OutputVector();
cout << "Второй вектор: " << endl;
b.OutputVector();
c = x*y;
cout << "Произведение первой и второй матрицы равно:" << endl;
c.OutputMatrix();
d = x + y;
cout << "Сумма матриц равна:" << endl;
d.OutputMatrix();
cout << "Введите число на которое будет умножена матрица: ";
cin >> num;
x.NumberMatrix(num);
cout << "Умножение матрицы на вектор:" << endl;
cout << "Умножение вектора на матрицу:" << endl;
MultVectorMatrix(x,a);
cout << "Сложение векторов:" << endl;
g = a + b;
g.OutputVector();
getch();