Results 1 to 6 of 6

Thread: my code compiles and executes but it does not show anything at display

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2016
    Posts
    10
    Platforms
    Windows

    Default my code compiles and executes but it does not show anything at display

    This code I wrote it myself but I do not get the expected output, just a message saying press enter to continue, the code is about emulating parts of an ATM.

    what I expect the program to do is the constructor of the class "Cuenta1()" to automatically call and execute the class function "establecerValores()", so that establecerValores() can automatically call and execute pedirContrasenia(), so that pedirContrasenia() can call and execute mostrarMensaje() just by declaring
    "Cuenta1 CuentaLuis();" within main.

    Qt Code:
    1. //****************( "Cuenta.h " )****************
    2.  
    3. #include<string>
    4. using namespace std;
    5.  
    6. class Cuenta1{
    7.  
    8. public:
    9.  
    10. Cuenta1();
    11.  
    12. void establecerValores( string, int, int );
    13.  
    14. string obtenerUsuario( );
    15.  
    16. int obtenerEdad();
    17.  
    18. int obtenerMonto();
    19.  
    20. void pedirContrasenia();
    21.  
    22. void mostrarMensaje();
    23.  
    24. private:
    25.  
    26. string nombreUsuario;
    27. int edadUsuario;
    28. int montoUsuario;
    29. int contraseniaUsuario;
    30. };
    31.  
    32. //****************( " end of Cuenta.h " )****************
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. //****************( " Cuenta.cpp " )****************
    2.  
    3. #include<iostream>
    4. #include"Cuenta.h"
    5. using namespace std;
    6.  
    7. Cuenta1::Cuenta1(){
    8.  
    9. establecerValores( "Luis Alberto Sánchez M", 28, 3600 );
    10. }
    11.  
    12. void Cuenta1::establecerValores( string nombre, int edad, int monto ){
    13.  
    14. nombreUsuario = nombre;
    15. edadUsuario = edad;
    16. montoUsuario = monto;
    17. pedirContrasenia();
    18. }
    19.  
    20. string Cuenta1::obtenerUsuario(){
    21.  
    22. return nombreUsuario;
    23. }
    24.  
    25. int Cuenta1::obtenerEdad(){
    26.  
    27. return edadUsuario;
    28. }
    29.  
    30. int Cuenta1::obtenerMonto(){
    31.  
    32. return montoUsuario;
    33. }
    34.  
    35. void Cuenta1::pedirContrasenia(){
    36.  
    37. int contraseniaActual = 1988;
    38. cout << "Por favor introduzca su contraseña : ";
    39. cin >> contraseniaUsuario;
    40. cout << "\n\n";
    41.  
    42. if( contraseniaUsuario == contraseniaActual )
    43.  
    44. mostrarMensaje();
    45.  
    46. if( contraseniaUsuario != contraseniaActual )
    47.  
    48. cout << "\n\n";
    49. cout << "Usted ingreso una contraseña incorrecta se se reinicializara el sistema\n"
    50. << "por favor introduzca la contraseña correcta la proxima vez" << "\n\n" ;
    51.  
    52. }
    53.  
    54. void Cuenta1::mostrarMensaje(){
    55.  
    56. cout << "Bienvenido a cajeros Nature : " << obtenerUsuario() << " Edad " << obtenerEdad() << "usted tiene $ " << obtenerMonto() << "\n\n";
    57. }
    58.  
    59. //****************( " end of cuenta.cpp " )****************
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. //****************( " main.cpp " )****************
    2.  
    3. #include<iostream>
    4. #include<cstdlib>
    5. #include "Cuenta.h"
    6. using namespace std;
    7.  
    8. int main(){
    9.  
    10. Cuenta1 cuentaLuis();
    11.  
    12. system("PAUSE");
    13. return 0;
    14. }
    15.  
    16. //****************( " end of main.cpp " )****************
    To copy to clipboard, switch view to plain text mode 
    Last edited by sauerplayer; 5th November 2016 at 07:13.

Similar Threads

  1. JS not executes in QTWebkit
    By ericzhang in forum Qt Programming
    Replies: 3
    Last Post: 25th March 2014, 11:31
  2. Create And Display QWidget in code
    By ShapeShiftme in forum Qt Programming
    Replies: 4
    Last Post: 19th May 2012, 07:04
  3. qt I want my widget show security code from web
    By insert in forum Qt Programming
    Replies: 7
    Last Post: 1st December 2010, 18:58
  4. Dialog executes in debug build but not release
    By awhite1159 in forum Qt Programming
    Replies: 5
    Last Post: 24th June 2008, 17:51
  5. Plugin ctor executes, but not dtor ?
    By scollyer in forum Qt Programming
    Replies: 1
    Last Post: 12th January 2008, 14:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.