Разбор Ошибок.перегрузка Операторов

09.02.2013
1
0
#1
Ну не могу самостоятельно разобрать свои ошибки.Они по большей части повторяются. Помогите пожалуйста.

ошибки следующие:
14 `Matrica Matrica::operator<(Matrica&, Matrica&)' must take exactly one argument
In function `Matrica operator<(Matrica&, Matrica)':
58 no match for 'operator=' in 'rez = P1->Matrica::stroka'
note D:\Ó×ÅÁÀ\àëãîðèòìè÷åñêèå ÿçûêè\21.cpp:15 candidates are: Matrica Matrica::operator=(Matrica&)
59 no match for 'operator=' in 'rez = P2.Matrica::stroka'
note :15 candidates are: Matrica Matrica::operator=(Matrica&)
In member function `Matrica Matrica::operator=(Matrica&)':
63 no matching function for call to `Matrica::Matrica(int&)'
noteD:\Ó×ÅÁÀ\àëãîðèòìè÷åñêèå ÿçûêè\21.cpp :6 candidates are: Matrica::Matrica(const Matrica&)
note D:\Ó×ÅÁÀ\àëãîðèòìè÷åñêèå ÿçûêè\21.cpp:6 Matrica::Matrica()
In function `int main()':
92 no match for 'operator=' in 'V = operator<(Matrica&, Matrica)(M2)'
note D:\Ó×ÅÁÀ\àëãîðèòìè÷åñêèå ÿçûè\21.cpp:63 candidates are: Matrica Matrica::operator=(Matrica&)



Задание:V=М1< М2 – из М1 и М2 выбрать строку с наименьшей суммой элементов. М1,М2 матрицы. V - массив
C++:
#include<iostream>/*zagolovochnij fajl s klassami, funktsijami i peremennimi dlja organizacii vvoda-vivoda v jazike programmirovaniya C++*/
/*#include <stdlib.h>*/
using namespace std;/*ob'javlenie prostranstva imen std.*/

class Matrica
{ float *x; float *a;
public:float sum, min; int stroka;int k;int n,m;
Matrica(); 
void vvod();
void vivod(); 
void min_sum_el();
void vivod_stroka();
void ww();
Matrica operator< (Matrica& ob1, Matrica& ob2);
Matrica operator=(Matrica& ob2);
~Matrica(){delete[]x; puts("rabotal destryktor\n");}				
};

Matrica::Matrica()
{/*printf("\nvvedite razmernost n*m: ");*/
scanf("%d %d",&n,&m);
puts("\nrabotal konstruktor matrici\n");	
} 
//==============================================//  
void Matrica:: vvod()	
{x = new float [n*m]; 
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
*(x + i * m + j) = rand() % 101 - 50;
}
//==============================================//
void Matrica::vivod()/*vivodit matrici na ekran*/
{printf("\nmatrica:\n"); 
for(int i = 0; i < n; i++)
{for(int j = 0; j < m; j++)
cout<<*(x + i * m + j)<< " ";
cout << "\n";
} 
}
//==============================================//	
void Matrica::min_sum_el()
{min = 1000;/*prinimayem za minimum samoye bolshoye chislo tipa 1000*/
for(int i = 0; i < n; i++)/*idem po strokam*/
{sum = 0;/*snachala summa v stroke=0*/
for(int j = 0; j < m; j++)/*idem po stroke*/
sum+= *(x + i * m + j);/*summiruyem yeye elementy*/
if (sum < min) 
{min = sum; stroka = i + 1;}/*esli summa v dannoy stroke menshe chem predydushchiy minimum to eto minimum i zapomnim nomer stroki*/
}
}
//==============================================//	 
void Matrica::vivod_stroka()
{printf("Minimalnaya summa= %3.2f v stroke %d ",min, stroka); printf("\n");}
//==============================================// 

Matrica operator<(Matrica& P1, Matrica P2) 
{Matrica rez; 
if (P1.stroka < P1.stroka) rez = P1.stroka;
else rez = P2.stroka;
return rez;  }
//==============================================//		 
Matrica Matrica::operator=(Matrica& P1)
{Matrica rez(P1.n);
for(int i = 0; i < n; i++)
*(a + i * m) = *(P1.x + i*P1.m);
return * this;
}

//==============================================// 
void Matrica::ww()
{for(int i = 0; i < n; i++)
cout<<*(a + i)<< " ";
cout << "\n";
}				

int main()
{Matrica M1;
M1.vvod();
M1.vivod();
M1.min_sum_el();
M1.vivod_stroka();
system("pause");

Matrica M2;
M2.vvod();
M2.vivod();
M2.min_sum_el();
M2.vivod_stroka();
system("pause");

Matrica V;
V = M1 < M2;
V.ww();
system("pause");
}