Taschenrechner programmieren in C++

eriko

Grünschnabel
:( Hallo Leute,

ich programmiere gerade einen Taschenrechner in C++ mit Microsoft Visual Studio 2005.
Ich habe schon das Interface erstellt mit Button für die Zahlen und Operatoren und mit einem Label für die Ausgabe der Ergebnisse und fürs Erscheinen des Operationen.

Ich habe auch schon das Code für die Operation mithilfe von Klassen in einer Headerdatei gepackt.

Aber ich weiß überhaupt nicht, wie ich das Label und die Buttons verbinden kann.
Ich möchte z.B. auf 1 cliken und will , dass es auf dem Label angezeigt wird. Wie schreibt den Code dafür in M Visual Studio?
Wie kann ich Klassen aus der Headerdateien aufrufen?
Wie schreibt man den Code dafür?

Ich bitte Sie um Hilfe und es ist sehr dringend. muss das fertige Programm in 1 Woche abgeben.

Danke im Voraus für Ihre Hilfe

ciao
 
Hallo,

ich bin zwar ein total newbie, aber der Link, den du angegeben hast, führt zu einem Tutorial für einen Consolen-TR und soweit ich gelesen habe, benötigt der Threaderöffner hilfe zu einem TR mit GUI.

Worüber ich auch dankbar wäre..:)
 
hi ich gib mal meinen frei ;) aber nich zu viel klauen plz.

//Taschenrechner von Mark Paspirigilis.cpp - Mein erstes Projekt
#include <iostream>
#include <cmath>
#include <string>

using namespace std ;

int main ()
{

for ( int x = 1 ; x <= 900 ; x += 1 )
{
cout << "Marks Taschenrechnerprogramm 1.2" << endl ;
cout << endl ;
cout << "Waehlen sie den Rechenvorgang aus" << endl ;
cout << "Multiplikation [1]" << endl ;
cout << "Division [2]" << endl ;
cout << "Addition [3]" << endl ;
cout << "Subtraktion [4]" << endl ;
cout << "Quadrieren [5]" << endl ;
cout << "Quadratwurzel ziehen [6]" << endl ;
cout << "Beenden [0]" << endl ;
cout << "Bitte geben sie eine der oben genannten Ziffern als Rechenvorgang an." << endl ;
string y;
cin >> y;
if ( y >= "0" )
{
if ( y == "1" )
{
double sjdfgjpaspirgilisndfsdnj ;
double jdfjpaspirgilissjngjnsdn ;
double dsfgaerqewpaspirgilisipkl ;
cout << "Bitte geben sie die erste Zahl ein... " ;
cin >> sjdfgjpaspirgilisndfsdnj ;
cout << "Bitte geben sie die zweite Zahl ein... " ;
cin >> jdfjpaspirgilissjngjnsdn ;

dsfgaerqewpaspirgilisipkl = sjdfgjpaspirgilisndfsdnj * jdfjpaspirgilissjngjnsdn;
cout << "Das Ergebnis aus " << sjdfgjpaspirgilisndfsdnj << " x " << jdfjpaspirgilissjngjnsdn << " = " << dsfgaerqewpaspirgilisipkl << endl ; cout << endl ; cout << endl ;
cout << "Bitte enter druecken" << endl ;
fflush(stdin);
getchar();
}
if ( y == "2" )
{
double sjdfgjpaspirgilisndfsdnj ;
double jdfjpaspirgilissjngjnsdn ;
double dsfgaerqewpaspirgilisipkl ;
cout << "Bitte geben sie die erste Zahl ein... " ;
cin >> sjdfgjpaspirgilisndfsdnj ;
cout << "Bitte geben sie die zweite Zahl ein... " ;
cin >> jdfjpaspirgilissjngjnsdn ;

dsfgaerqewpaspirgilisipkl = sjdfgjpaspirgilisndfsdnj / jdfjpaspirgilissjngjnsdn;
cout << "Das Ergebnis aus " << sjdfgjpaspirgilisndfsdnj << " : " << jdfjpaspirgilissjngjnsdn << " = " << dsfgaerqewpaspirgilisipkl << endl ; cout << endl ; cout << endl ;
cout << "Bitte enter druecken" << endl ;
fflush(stdin);
getchar();
}
if ( y == "3" )
{
double sjdfgjpaspirgilisndfsdnj ;
double jdfjpaspirgilissjngjnsdn ;
double dsfgaerqewpaspirgilisipkl ;
cout << "Bitte geben sie die erste Zahl ein... " ;
cin >> sjdfgjpaspirgilisndfsdnj;
cout << "Bitte geben sie die zweite Zahl ein... " ;
cin >> jdfjpaspirgilissjngjnsdn;

dsfgaerqewpaspirgilisipkl = sjdfgjpaspirgilisndfsdnj + jdfjpaspirgilissjngjnsdn;
cout << "Das Ergebnis aus " << sjdfgjpaspirgilisndfsdnj << " + " << jdfjpaspirgilissjngjnsdn << " = " << dsfgaerqewpaspirgilisipkl << endl ; cout << endl ; cout << endl ;
cout << "Bitte enter druecken" << endl ;
fflush(stdin);
getchar();
}
if ( y == "4" )
{
double sjdfgjpaspirgilisndfsdnj ;
double jdfjpaspirgilissjngjnsdn ;
double dsfgaerqewpaspirgilisipkl ;
cout << "Bitte geben sie die erste Zahl ein... " ;
cin >> sjdfgjpaspirgilisndfsdnj;
cout << "Bitte geben sie die zweite Zahl ein... " ;
cin >> jdfjpaspirgilissjngjnsdn;

dsfgaerqewpaspirgilisipkl = sjdfgjpaspirgilisndfsdnj - jdfjpaspirgilissjngjnsdn;
cout << "Das Ergebnis aus" << sjdfgjpaspirgilisndfsdnj << " - " << jdfjpaspirgilissjngjnsdn << " = " << dsfgaerqewpaspirgilisipkl << endl ; cout << endl ; cout << endl ;
cout << "Bitte enter druecken" << endl ;
fflush(stdin);
getchar();
}
if ( y == "5" )
{
double sjdfgjpaspirgilisndfsdnj ;
double dsfgaerqewpaspirgilisipkl ;
cout << "Bitte geben sie die zu potenzierende Zahl ein... " ;
cin >> sjdfgjpaspirgilisndfsdnj;

dsfgaerqewpaspirgilisipkl = sjdfgjpaspirgilisndfsdnj * sjdfgjpaspirgilisndfsdnj;
cout << "Das Quadrat aus" << sjdfgjpaspirgilisndfsdnj << " = " << dsfgaerqewpaspirgilisipkl << endl ; cout << endl ; cout << endl ;
cout << "Bitte enter druecken" << endl ;
fflush(stdin);
getchar();
}
if ( y == "6" )
{
double sjdfgjpaspirgilisndfsdnj ;
double dsfgaerqewpaspirgilisipkl ;
cout << "Bitte geben sie die erste Zahl ein... " ;
cin >> sjdfgjpaspirgilisndfsdnj ;

dsfgaerqewpaspirgilisipkl = sqrt (sjdfgjpaspirgilisndfsdnj);
cout << "Die Wurzel aus" << " = " << dsfgaerqewpaspirgilisipkl << endl ; cout << endl ; cout << endl ;
cout << "Bitte enter druecken" << endl ;
fflush(stdin);
getchar();
}
if ( y == "0" )
{
x = x + 899;
}
}
else
{
cout << "Rechenweg nicht vorhanden" << endl ; cout << endl ; cout << endl ;
cout << "Bitte enter druecken" << endl ;
fflush(stdin);
getchar();
}
}
cout << "Dieses Programm ist Beendet" << endl ;
fflush(stdin);
getchar();
return 0;
}
 
Auch das ist keine GUI-Variante. Aber nette Variablen hast du ;-)
Bitte in Zukunft Code-Blöcke verwenden, der Lesbarkeit zuliebe.
Allgemein klickt man den Button doppelt an und schreibt da seine Funktion rein, da gibts es bestimmt haufenweise Tutos für, die mit einer renommierten Suchmaschine gefunden werden dürfte.
 
Suche bei Google nach GetWindowText und SetWindowText

Klasse erstellen...
Code:
#ifndef __MeineKlasse_h__
#define __MeineKlasse_h__

class MeineKlasse
{
   //Code
};

#endif

Klasse einbinden :
Code:
# include "MeineKlasse.h"
 
Zuletzt bearbeitet:

Neue Beiträge

Zurück