Guest User

Untitled

a guest
Apr 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include "konto.h"
  2. bool getKonto(Konto *pKonto);
  3.  
  4. int main()
  5. {
  6.     Konto giro1, giro2, *ptr = &giro1;
  7.  
  8.     ptr->init("Munter, Gabi",3512345, 99.40);
  9.  
  10.     ptr->display();
  11.  
  12.     ptr = &giro2;
  13.     if ( getKonto(ptr))
  14.         ptr-> display();
  15.     else
  16.         cout << "Ungueltige Eingabe!"<< endl;
  17.  
  18.  
  19.     cin.get();
  20.     cin.sync();
  21.     return 0;
  22. }
  23.  
  24. bool getKonto(Konto *pKonto)
  25. {
  26.     string name, line(50,'-');
  27.     unsigned long nr;
  28.     double startkapital;
  29.  
  30.     cout << line << '\n'
  31.          << "Daten für ein neues Konto eingeben: \n"
  32.          << "Kontoinhaber: ";
  33.     if (!getline(cin,name) || name.size() == 0)
  34.         return false;
  35.     cout << "Kontonummer: ";
  36.     if (! (cin >> nr))              return false;
  37.     cout << "Startkapital: ";
  38.     if (!(cin >> startkapital))     return false;
  39.     pKonto ->init(name, nr, startkapital);
  40.     return true;
  41. }
Add Comment
Please, Sign In to add comment