voila j'ai un tout petit code que j'essaie de compiler sous devc++, mais n'y arrive pas.
voici le codeet 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
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 #include <cstdlib> #include <iostream> #include <ctype.h> #include <string.h> using namespace std; class Personne { public: class error {}; class error_name : public error {}; Personne(); ~Personne(); Personne(char*); void Modifier(); void Afficher(); protected: void edit_nom(); private: char *nom; }; Personne::Personne() { nom = new char[20]; this->edit_nom(); } Personne::~Personne() { delete[] nom; } void Personne::Modifier() { edit_nom(); } void Personne::edit_nom() { char temp[20]; cout << "saisir nom: "; cin >> temp; if(nom == NULL) { nom = new char[strlen(temp)+1]; } strcpy(nom, temp); } void Personne::Afficher() { if(nom == NULL) { throw error_name; } cout << "nom: " << nom << endl; } int main() { try { Personne p1; p1.Afficher(); } catch(Personne::error_name en) { cout << "exception error_name:" << endl; Personne::p1.edit_name(); } system("PAUSE"); return EXIT_SUCCESS; }
Je n'arrive pas à trouver où est ce que le code pêche..
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 C:\Dev-Cpp\newdev9ex2\main.cpp In member function `void Personne::Afficher()': 56 C:\Dev-Cpp\newdev9ex2\main.cpp expected primary-expression before ';' token C:\Dev-Cpp\newdev9ex2\main.cpp In function `int main()': 70 C:\Dev-Cpp\newdev9ex2\main.cpp `p1' is not a member of `Personne'
Partager