Précédent   Forum du club des développeurs et IT Pro > C et C++ > C++ > Débuter
Débuter Forum d'entraide pour débuter en langage de programmation C++. Avant de poster : cours d'initiation au C++
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 27/12/2012, 08h20   #1
info.pascal
Invité de passage
 
Inscription : avril 2009
Messages : 24
Détails du profil
Informations forums :
Inscription : avril 2009
Messages : 24
Points : 3
Points : 3
Par défaut comparaison entre deux nombres entier

Bonjour,

je travail avec Borland C++, je souhaite faire une comparaison entre deux nombres entier si (a<b) il m'affiche ("a plus grand") sinon il m'affiche ("b plus grand").

ma fenêtre contient 2 Edits : Edit1 'a' et Edit2 'b' et un bouton 'comparerButton'.

normalement lorsque je saisie un entier dans 'a' et l'autre dans 'b' et je clique sur 'comparerButton' il m'affiche un message ("a plus grand" ou "b plus grand").


Mon code complet:

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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
 
//---------------------------------------------------------------------------
 
 
#ifndef FichePrincipaleH
#define FichePrincipaleH
 
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
 
//---------------------------------------------------------------------------
 
 
//---------------------------------------------------------------------------
 
class TForm1 : public TForm
{
__published:	// Composants gérés par l'EDI
    TEdit *a;
    TEdit *b;
    TButton *comparerButton;
 
 
 
private:	// Déclarations utilisateur
public:		// Déclarations utilisateur
    __fastcall TForm1(TComponent* Owner);
};
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
 
 
//---------------------------------------------------------------------------
 
 
 
 
 
 
//---------------------------------------------------------------------------
 
 
void __fastcall TForm1::bEnter(TObject *Sender)
{
SetWindowLong(b->Handle,GWL_STYLE,
                GetWindowLong(b->Handle,GWL_STYLE)
                                            | ES_NUMBER );
 
}
//---------------------------------------------------------------------------
void __fastcall TForm1::aEnter(TObject *Sender)
{
SetWindowLong(a->Handle,GWL_STYLE,
                GetWindowLong(a->Handle,GWL_STYLE)
                                            | ES_NUMBER );
}
//---------------------------------------------------------------------------
 
void __fastcall TForm1::aChange(TObject *Sender)
{
     int a = 0;
    try { // L'exception sera déclenchée si le contenu de
          // la zone est vide
        valeur = StrToInt(a->Text);
    }
 
}
//---------------------------------------------------------------------------
 
 
void __fastcall TForm1::bChange(TObject *Sender)
{
     int b = 0;
    try { // L'exception sera déclenchée si le contenu de
          // la zone est vide
        valeur = StrToInt(b->Text);
    }
}
//---------------------------------------------------------------------------
 
void __fastcall TForm1::comparerButtonClick(TObject *Sender)
{
     	if (a>b){
	ShowMessage("a plus grand");}
 
             	else
	{ShowMessage("b plus grand");
 	}
 
}
//---------------------------------------------------------------------------
il m'affiche 5 problèmes qui sont :

Code :
1
2
3
4
5
6
7
8
9
10
 
  [C++ Error] Unit1.cpp(47): E2316 '_fastcall TForm1::bEnter(TObject *)' is not a member of 'TForm1'
 
  [C++ Error] Unit1.cpp(55): E2316 '_fastcall TForm1::aEnter(TObject *)' is not a member of 'TForm1'
 
  [C++ Error] Unit1.cpp(63): E2316 '_fastcall TForm1::aChange(TObject *)' is not a member of 'TForm1'
 
  [C++ Error] Unit1.cpp(75): E2316 '_fastcall TForm1::bChange(TObject *)' is not a member of 'TForm1'
 
  [C++ Error] Unit1.cpp(85): E2316 '_fastcall TForm1::comparerButtonClick(TObject *)' is not a member of 'TForm1'
j'attend vos réponse avec impatience.
Merci bien.
info.pascal est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2012, 10h00   #2
bacelar
Expert Confirmé Sénior
 
Homme Paul Bacelar
Développeur informatique
Inscription : février 2005
Messages : 2 651
Détails du profil
Informations personnelles :
Nom : Homme Paul Bacelar
Âge : 41
Localisation : France

Informations professionnelles :
Activité : Développeur informatique
Secteur : Conseil

Informations forums :
Inscription : février 2005
Messages : 2 651
Points : 4 044
Points : 4 044
Mauvais forum, ici c'est C++/CLI.

Pour ton problème, tu définis "__fastcall TForm1::bEnter" mais il n'est pas déclaré dans la définition de la classe (le contenu du fichier d'en-tête de la class).

Pareil pour les 4 autres erreurs.
bacelar est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/12/2012, 22h21   #3
info.pascal
Invité de passage
 
Inscription : avril 2009
Messages : 24
Détails du profil
Informations forums :
Inscription : avril 2009
Messages : 24
Points : 3
Points : 3
Citation:
Envoyé par bacelar Voir le message
Mauvais forum, ici c'est C++/CLI.

Pour ton problème, tu définis "__fastcall TForm1::bEnter" mais il n'est pas déclaré dans la définition de la classe (le contenu du fichier d'en-tête de la class).

Pareil pour les 4 autres erreurs.
merci bien pour votre réponse mais je suis débutante est ce que vous pouvez m'écrire l'instruction que je doit l'ajouter seulement pour une erreur SVP
info.pascal est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 31/12/2012, 11h09   #4
bacelar
Expert Confirmé Sénior
 
Homme Paul Bacelar
Développeur informatique
Inscription : février 2005
Messages : 2 651
Détails du profil
Informations personnelles :
Nom : Homme Paul Bacelar
Âge : 41
Localisation : France

Informations professionnelles :
Activité : Développeur informatique
Secteur : Conseil

Informations forums :
Inscription : février 2005
Messages : 2 651
Points : 4 044
Points : 4 044
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class TForm1 : public TForm
{
__published:	// Composants gérés par l'EDI
    TEdit *a;
    TEdit *b;
    TButton *comparerButton;
 
 
 
private:	// Déclarations utilisateur
public:		// Déclarations utilisateur
    __fastcall TForm1(TComponent* Owner);
    __fastcall bEnter(TObject *Sender);
   ...
};
bacelar est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/01/2013, 10h43   #5
info.pascal
Invité de passage
 
Inscription : avril 2009
Messages : 24
Détails du profil
Informations forums :
Inscription : avril 2009
Messages : 24
Points : 3
Points : 3
Citation:
Envoyé par bacelar Voir le message
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class TForm1 : public TForm
{
__published:	// Composants gérés par l'EDI
    TEdit *a;
    TEdit *b;
    TButton *comparerButton;
 
 
 
private:	// Déclarations utilisateur
public:		// Déclarations utilisateur
    __fastcall TForm1(TComponent* Owner);
    __fastcall bEnter(TObject *Sender);
   ...
};
MERCI BEAUCOUP

voici mon nouveau code :

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
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
75
76
77
78
79
 
#ifndef FichePrincipaleH
#define FichePrincipaleH
 
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
 
//---------------------------------------------------------------------------
 
 
//---------------------------------------------------------------------------
 
class TForm1 : public TForm
{
__published:	// Composants gérés par l'EDI
    TEdit *a;
    TEdit *b;
    TButton *comparerButton;
 
 
 
private:	// Déclarations utilisateur
public:		// Déclarations utilisateur
    __fastcall TForm1(TComponent* Owner);
    __fastcall bEnter(TObject *Sender);
    __fastcall aEnter(TObject *Sender);
    __fastcall comparerButtonClick(TObject *Sender);
};
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
 
 
//---------------------------------------------------------------------------
 
 
 
 
 
 
//---------------------------------------------------------------------------
 
 
int __fastcall TForm1::bEnter(TObject *Sender)
{
SetWindowLong(b->Handle,GWL_STYLE,
                GetWindowLong(b->Handle,GWL_STYLE)
                                            | ES_NUMBER );
 
}
//---------------------------------------------------------------------------
int __fastcall TForm1::aEnter(TObject *Sender)
{
SetWindowLong(a->Handle,GWL_STYLE,
                GetWindowLong(a->Handle,GWL_STYLE)
                                            | ES_NUMBER );
}
//---------------------------------------------------------------------------
 
 
//---------------------------------------------------------------------------
 
 
//---------------------------------------------------------------------------
 
int __fastcall TForm1::comparerButtonClick(TObject *Sender)
{
     	if (a>b){
	ShowMessage("a plus grand");}
 
             	else
	{ShowMessage("b plus grand");
 	}
 
};
//---------------------------------------------------------------------------
les nouveaux erreurs :

Code :
1
2
3
4
5
 
[C++ Warning] Unit1.cpp(52): W8070 Function should return a value
[C++ Warning] Unit1.cpp(59): W8070 Function should return a value
[C++ Error] Unit1.cpp(71): E2268 Call to undefined function 'ShowMessage'
[C++ Warning] Unit1.cpp(77): W8070 Function should return a value
j'ai essayé le même code avec void ça m'a donné :

Code :
1
2
3
4
5
6
7
8
9
 
Build
  [C++ Error] Unit1.cpp(47): E2316 '_fastcall TForm1::bEnter(TObject *)' is not a member of 'TForm1'
  [C++ Warning] Unit1.cpp(52): W8070 Function should return a value
  [C++ Error] Unit1.cpp(55): E2316 '_fastcall TForm1::aEnter(TObject *)' is not a member of 'TForm1'
  [C++ Warning] Unit1.cpp(59): W8070 Function should return a value
  [C++ Error] Unit1.cpp(69): E2316 '_fastcall TForm1::comparerButtonClick(TObject *)' is not a member of 'TForm1'
  [C++ Error] Unit1.cpp(71): E2268 Call to undefined function 'ShowMessage'
  [C++ Warning] Unit1.cpp(77): W8070 Function should return a value
info.pascal est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/01/2013, 11h59   #6
bacelar
Expert Confirmé Sénior
 
Homme Paul Bacelar
Développeur informatique
Inscription : février 2005
Messages : 2 651
Détails du profil
Informations personnelles :
Nom : Homme Paul Bacelar
Âge : 41
Localisation : France

Informations professionnelles :
Activité : Développeur informatique
Secteur : Conseil

Informations forums :
Inscription : février 2005
Messages : 2 651
Points : 4 044
Points : 4 044
Il faut que les signatures de méthodes soient identiques dans le .cpp ET dans le .h

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class TForm1 : public TForm
{
__published:	// Composants gérés par l'EDI
    TEdit *a;
    TEdit *b;
    TButton *comparerButton;
 
 
 
private:	// Déclarations utilisateur
public:		// Déclarations utilisateur
    __fastcall TForm1(TComponent* Owner);
    void __fastcall bEnter(TObject *Sender);
   ...
};
Code :
1
2
3
4
5
6
7
void __fastcall TForm1::bEnter(TObject *Sender)
{
SetWindowLong(b->Handle,GWL_STYLE,
                GetWindowLong(b->Handle,GWL_STYLE)
                                            | ES_NUMBER );
 
}
bacelar est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/02/2013, 01h07   #7
info.pascal
Invité de passage
 
Inscription : avril 2009
Messages : 24
Détails du profil
Informations forums :
Inscription : avril 2009
Messages : 24
Points : 3
Points : 3
Merci beaucoup.
::
info.pascal est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 05h36.


 
 
 
 
Partenaires

Hébergement Web