cs_paras00
Messages postés6Date d'inscriptionmercredi 13 décembre 2000StatutMembreDernière intervention19 mai 2010
-
7 févr. 2010 à 18:45
cs_neone
Messages postés96Date d'inscriptionmercredi 23 novembre 2005StatutMembreDernière intervention 7 mars 2011
-
8 févr. 2010 à 05:46
Bonjour ;
j'aimerai bien ke vous m'aidez à resoudre une erreur dans mon programme
#include
typedef void* T ;
class element
{
friend class liste;
T valeur;
element *next;
element(int a)
{valeur=(T)a;next=NULL;}
};
class liste
{
T courant;
public :
liste :: liste( const liste & uneListe )
{
* this = uneListe;
}
liste(){courant=NULL;}
int vide ();
void initialiser ();
void ajouter (T);
int longuer();
void afficher();
};
int liste::vide()
{
if(courant==NULL)
return 1;
else return 0;
}
void liste::initialiser()
{
if(!vide())
{
courant = NULL;
}
}
void liste::ajouter(T v)
{
void* tmp=courant;
void* nouveau = new T(v);
((*nouveau)->valeur) = v;
nouveau->next = NULL;
if(vide()) courant = nouveau;
else
{
tmp = courant;
while(tmp->next !NULL) tmp tmp->next;
tmp->next = nouveau;
}
}
void liste::afficher()
{
void* tmp;
if(vide()) cout<<" !la liste est vide!\n";
else
{
tmp = courant;
while(tmp != NULL)
{
cout<<((tmp)->valeur)<<" ";
tmp = tmp->next;
}
cout<<" - longueur : "<<longuer()<<endl;
}
}
int liste::longuer()
{
int l=0;
void* tmp = courant;
while(tmp != NULL)
{
l++;
tmp = tmp->next;
}
return l;
}
int main ()
{
liste * L = new liste();
int choix;
int v;
do
{
cout<<"1-Nouvelle Liste.\n";
cout<<"2-Ajouter Element.\n";
cout<<"6-Afficher.\n";
cout<<"0-Quitter.\n";
cout<<" -->choix(0-6):"; cin>>choix;
switch(choix)
{
case 1:
L->initialiser();
break;
case 2:
cout<<" - Entrer une valeur : "; cin>>v;
L->ajouter((T)v);
break;
case 6:
L->afficher();
break;
}
}while(choix != 0);
return 0;
}
Il me donne comme erreur :
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\backward\backward_warning.h|32|warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or instead of the deprecated header . To disable this warning use -Wno-deprecated.|
C:\Documents and Settings\user\Bureau\lis.cpp||In member function `void liste::ajouter(void*)':|
C:\Documents and Settings\user\Bureau\lis.cpp|46|error: `void*' is not a pointer-to-object type|
C:\Documents and Settings\user\Bureau\lis.cpp|47|error: `void*' is not a pointer-to-object type|
C:\Documents and Settings\user\Bureau\lis.cpp|52|error: `void*' is not a pointer-to-object type|
C:\Documents and Settings\user\Bureau\lis.cpp|52|error: `void*' is not a pointer-to-object type|
C:\Documents and Settings\user\Bureau\lis.cpp|53|error: `void*' is not a pointer-to-object type|
C:\Documents and Settings\user\Bureau\lis.cpp||In member function `void liste::afficher()':|
C:\Documents and Settings\user\Bureau\lis.cpp|123|error: `void*' is not a pointer-to-object type|
C:\Documents and Settings\user\Bureau\lis.cpp|124|error: `void*' is not a pointer-to-object type|
C:\Documents and Settings\user\Bureau\lis.cpp||In member function `int liste::longuer()':|
C:\Documents and Settings\user\Bureau\lis.cpp|136|error: `void*' is not a pointer-to-object type|
||Build finished: 8 errors, 1 warnings|
cs_neone
Messages postés96Date d'inscriptionmercredi 23 novembre 2005StatutMembreDernière intervention 7 mars 2011 8 févr. 2010 à 05:46
Bonsoir, le code a pour but la création d'une liste chainée dont les valeurs c des void *. ya déja une mal comprehension des listes chainées que ce soir double ou simple.
faudra penser a faire un truk dans ce genre:
classe liste
{
element courant;
element suivant;
}
classe element
{
avec ton void * ou ce que tu ve.
}
aprés c a toi de voir.
boncourage