Bonjour,

j'ai cree une structure maillon et j'aimerais creer une fonction qui me retourne un element de cet structure maillon voila comment j'ai procéder :

dans mon Cpp :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
maillon *  ListeInt::Retourner( )
{
 
	maillon *tmp;
	tmp = new maillon;
 
 
	return tmp;
 
}

Dans mon .h :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
class ListeInt
 
{
 
public:
 
	[....]
 
	maillon * Retourner();
 
 
 
private:
 
 
struct maillon
 
	{
 
		int Val;
 
		maillon *Suiv;
 
	};
 
 
 
 
};

mais il ne reconnais pas le maillon comme un element de ma structure voici les erreurs :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
ompiling...
liste.cpp
c:\documents and settings\bureau\c++\seance 2\liste_2\liste\liste.h(45) : error C2143: syntax error : missing ';' before '*'
c:\documents and settings\bureau\c++\seance 2\liste_2\liste\liste.h(45) : error C2501: 'maillon' : missing storage-class or type specifiers
c:\documents and settings\\bureau\c++\seance 2\liste_2\liste\liste.h(45) : error C2501: 'Retourner' : missing storage-class or type specifiers
c:\documents and settings\r\bureau\c++\seance 2\liste_2\liste\liste.cpp(411) : error C2143: syntax error : missing ';' before '*'
c:\documents and settings\\bureau\c++\seance 2\liste_2\liste\liste.cpp(411) : error C2501: 'maillon' : missing storage-class or type specifiers
c:\documents and settings\\bureau\c++\seance 2\liste_2\liste\liste.cpp(412) : error C2501: 'Retourner' : missing storage-class or type specifiers
c:\documents and settings\\bureau\c++\seance 2\liste_2\liste\liste.cpp(418) : error C2440: 'return' : cannot convert from 'struct ListeInt::maillon *' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
main.cpp
c:\documents and settings\\bureau\c++\seance 2\liste_2\liste\liste.h(45) : error C2143: syntax error : missing ';' before '*'
c:\documents and settings\\bureau\c++\seance 2\liste_2\liste\liste.h(45) : error C2501: 'maillon' : missing storage-class or type specifiers
c:\documents and settings\\bureau\c++\seance 2\liste_2\liste\liste.h(45) : error C2501: 'Retourner' : missing storage-class or type specifiers
Error executing cl.exe.
 
liste.exe - 10 error(s), 0 warning(s)
Voila en vous remerciant