0

help me with global variable and local variable

I want to implement double linked list and get max, min, med from it, but my compiler says the global variable and local variable overrides. I want my max, min stored in global variable and always use it in search algorithm but the error keeps obstructing me. Could help me with the code? https://code.sololearn.com/c4eHSh6RfW8V/#cpp _____________________________________ #include <fstream> #include <string> #include <sstream> #include <vector> #include "DLinkedList.h" ifstream inputfile; ofstream outputfile; int max = 0; int min = 0; int med = 0; _______________~~~~~__________________ void DLinkedList::add(int val, const Elem& e) { DNode* u = new DNode; DNode* s = new DNode; s = header; u->elem = e; u->value = val; if (empty() == 1) addBack(u); else { while (s->next->value > u->value) { s = s->next; if (s->next->value > u->value) { u->next = s->next; u->prev = s; u->prev->next = s->next->prev = u; } } } max = trailer->prev->value; min = header->next->value; med = findmedian(header); }

27th Apr 2020, 1:06 PM
김도현
김도현 - avatar
1 Resposta
0
This is not the full code. What is written inside DLinkedList.h header file? You can try changing spelling of ur min, max to minn, maxx. I am not sure that this will work but u should try once. Post ur complete code.
27th Apr 2020, 1:41 PM
Peter Parker
Peter Parker - avatar