[résolu] [débutant] doit utiliser g++ -fpermissive
bonjour bonjour !
alors voilà, je prends la suite d'un petit projet développé en c++, langage dont j'ai pas l'habitude (je suis plutôt java).
un fichier pose problème : il génère des erreurs qui me forcent à utiliser g++ -fpermessive pour en faire des warnings.
de plus, ce fichier implémente une liste chaînée et j'ai besoin d'utiliser son opérateur [], lequel déconne.
quelqu'un pourrait-il m'aider à corriger ce fichufichier ?
voici le fichier :
Code:
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
|
/**
* List.h
*/
#include <vector>
using namespace std;
template<class T>
class List :
private vector<T>
{
public:
List(void){};
~List(void){};
int length(){return (int)size();}
bool isEmpty(){return empty();}
void add(T element){push_back(element);}
T pop()
{int r=last(); pop_back();return r;}
T operator[](int rank){return at(rank);}
int last(){return at(size()-1);}
int first(){return at(0);}
void clear(){vector<T>::clear();}
void append(List<T> liste)
{for(int i=0;i<(int)liste.size();i++)add(liste[i]);}
void replace(T element,int offset );
void erase(int offset){vector<T>::erase(begin()+offset);}
};
template <class T> inline void List<T>::replace(T element,int offset )
{
insert(begin()+offset,element);
erase(offset+1);
} |
voilà les warnings qui apparaissent quand je compile un .cpp utilisant ce fichier List.h en utilisant "g++ -fpermissive" :
Citation:
List.h: In member function `int List<T>::length()':
List.h:39: warning: there are no arguments to `size' that depend on a template parameter, so a declaration of `size' must be available
List.h: In member function `bool List<T>::isEmpty()':
List.h:40: warning: there are no arguments to `empty' that depend on a template parameter, so a declaration of `empty' must be available
List.h: In member function `T List<T>::pop()':
List.h:43: warning: there are no arguments to `pop_back' that depend on a template parameter, so a declaration of `pop_back' must be available
List.h: In member function `T List<T>::operator[](int)':
List.h:47: warning: there are no arguments to `at' that depend on a template parameter, so a declaration of `at' must be available
List.h: In member function `int List<T>::last()':
List.h:48: warning: there are no arguments to `size' that depend on a template parameter, so a declaration of `size' must be available
List.h: In member function `int List<T>::first()':
List.h:49: warning: there are no arguments to `at' that depend on a template parameter, so a declaration of `at' must be available
List.h: In member function `void List<T>::erase(int)':
List.h:54: warning: there are no arguments to `begin' that depend on a template parameter, so a declaration of `begin' must be available
List.h: In member function `void List<T>::replace(T, int)':
List.h:61: warning: there are no arguments to `begin' that depend on a template parameter, so a declaration of `begin' must be available
quand je compile sans "-fpermissive", j'ai simplement des "error" à la place des "warning", et un message disant que je peux à la limite utiliser -fpermissive".
pour info, ce projet utilise l'environnement de compilation mingw32.
voilà, j'espère avoir été suffisamment clair.... si quelqu'un pouvait m'aider çà me rendrait vraiment un grand service :-).
merci !