No match for ‘operator=’ c++ ошибка?
Ошибка на c=a-b;
Проблема с типами походу.
[Error] no match for ‘operator=’ (operand types are ‘massiv’ and ‘massiv’)
Не могу понять что он от меня хочет) Как исправить, подскажите добрые люди?
Комментировать
Решения вопроса 1
«I’m here to consult you» © Dogbert
massiv operator=(massiv &w)
должно быть
massiv& operator=(const massiv &w)
const в параметрах — важен.
Ответ написан более двух лет назад
Комментировать
Нравится Комментировать
Ответы на вопрос 2
Developer, ex-admin
Оператор присваивания должен возвращать ссылку на самого себя. У вас возвращается копия объекта.
Ответ написан более двух лет назад
Ошибка error: no match for ‘operator>>’
Я смотрел кучу вопросов, и не мог найти ответ, специально для моего. Таким образом, я продолжаю получать ошибки в этом коде. Был бы очень признателен за вашу помощь.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#include #include #include #include #include using namespace std; int main() { setlocale(LC_ALL, "rus"); struct Timpul { int CodZien; float Temperatura; float Umiditatea; char DirVint [50]; float VitezaVint; } ziua[1000]; int n; cout"Введите количество данных: "; cin>>n; ofstream file ("Timpul.txt"); file.close(); for(int i=0; in; i++) { cout "Введите код дня " endl; cin>>ziua[i].CodZien; cout "Введите температуру дня "endl; cin>>ziua[i].Temperatura; cout "Введите процент влажности "endl; cin>>ziua[i].Umiditatea; cout "Введите направление ветра (не определено, север, юг, восток, запад, северо-запад) "endl; cin>>ziua[i].DirVint; cout "Введите скорость ветра в метрах в секунду "endl; cin>>ziua[i].VitezaVint; } int i; ifstream in ("Timpul.txt"); in.open("Timpul.txt"); for(int i=0; in; i++) { in>>ziua[i].CodZien>>"\t">>ziua[i].Temperatura>>"\t">>ziua[i].Umiditatea>>endl; in.close(); return 0; }
Добавлено через 8 минут
Ещё мне нужно сделать так, чтобы результат, который выводится на экран, записывался в текстовый файл.
Буду благодарен тем, кто поможет.
Заранее спасибо!
No match for operator c как исправить
Seems quite unlikely
Last edited on
Why can’t I assign things like this with template code? |
Take a look at line 9/10. You have an int there where you should have T .
Apart from the resize(. ) problem.
No match for 'operator!='
but you did not tell where.
In this case the where is lines 16 and 21. In fact, those lines have also:
No match for 'operator='
If we look at line 16: for (b1 = B.begin(); b1 != B.end(); b1++) with the types of objects:
1
2
3
4
5
6
void copy(vector B, vector A)< vectorint>::iterator b1; for ( b1 = B.begin(); b1 != B.end(); b1++ ) vectorfloat> V1, V2; copy( V2, V1 );
we see that the operands on both cases are vector int >::iterator and vector float >::iterator ,
then we reach to the explanation.
Or, as a compiler says:
16:9: error: no match for 'operator=' (operand types are 'std::vector::iterator>' and 'std::vector::iterator >') 16:25: error: no match for 'operator!=' (operand types are 'std::vector::iterator >' and 'std::vector::iterator >')
Focus on these:
* Where does the (syntax) error occur?
* What is in there?
* What does the compiler tell?
No match for operator c как исправить
Сообщений: 64
no match for ‘operator=’
Не могу понять, что этой программке еще нужно
#include using namespace std; class matrica; class massiv < public:float *a; int n;float sum1; massiv(); void vivod(); massiv& massiv:: operator=(massiv& /*ob*/); massiv ( massiv & f); void sum_el(); void vivod_sum_el(); ~massiv()>; //=====================// massiv::massiv() //======================// void massiv::vivod() ////===================// void massiv::sum_el() > //=====================// void massiv::vivod_sum_el() //======================/ massiv& massiv::operator=(massiv& P2) //=================// massiv::massiv(massiv & f)/*konstruktor kopii massiva*/ //===================// class matrica < float *x; int n,m; public: float sum,min_s;float sum2; int stroka; int i,j;int kol_str; matrica(); void vvod(); void vivod(); void sum_el(); void vivod_sum_el(); void min_str(); massiv operator<<( /*const*/ matrica &); matrica operator-(massiv &mas); ~matrica() >; //=========================// matrica::matrica() //========================// void matrica:: vvod() //=======================// void matrica::vivod() > //=========================// void matrica::min_str() printf("Minimalnaya summa= %3.2f v stroke %d ",min_s, stroka); printf("\n"); > > //==================// massiv matrica:: operator <<( /*const */matrica & p1) else /*if (min_s return rez; > /*--------------------------------*/ void matrica::sum_el() > /*--------------------------------*/ void matrica::vivod_sum_el()*printf("\nsumma= %3.2f v stroke %d ",sum2, stroka); > printf("\n"); printf("koli4estvo strok novoj matrici = %d",kol_str);printf("\n");*/ cout /*--------------------------------*/ matrica matrica::operator-(massiv &p) return r; > /*-----------------------------*/ int main()
Вроде бы разобралась что к чему — а тут эта ошибка:
In function `int main()’:
173 D:\. \. cpp no match for ‘operator=’ in ‘V = matrica:perator <<(matrica&)(((mat rica&)(&M2)))'
note D:\. \. cpp:48 candidates are: massiv& massiv:perator=(massiv&)
подсказка говорит что нужна перегрузка оператора = или как. уже ничего не понимаю..как сделать програмку рабочей??
lisica198808 |
Посмотреть профиль |
Найти ещё сообщения от lisica198808 |