pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

C++ pastebin - collaborative debugging tool View Help


Posted by EnDleSs_DaRk on Wed 2 Sep 10:07
report abuse | download | new post

  1. #include <iostream>
  2.  
  3. //Clase celda
  4. class objeto {
  5.         private:
  6.            int valor;
  7.         public:
  8. //Set tipo de celda
  9. void decValor(){
  10. valor--;
  11. }
  12.  
  13. //Imprime el valor
  14. void impValor(){
  15. printf("valor:%d\n",valor);
  16. }
  17.  
  18. //Constructor de la clase celda
  19. objeto(int quevalor){
  20. valor=quevalor;
  21. }
  22.  
  23. //Comprueba si es cero
  24. bool es_cero(){
  25. if (valor==0) return true;
  26. else return false;;
  27. }
  28.  
  29. //Constructor que copia
  30. objeto(const objeto& ref) {       // construtor-copia
  31.  valor = ref.valor;
  32.  }
  33. };
  34.  
  35. //Funcion chunga y recursiva!
  36. void recursion(objeto actual){
  37.  
  38. objeto aux = actual;
  39.  
  40. if (actual.es_cero()) printf("Se acabó!!\n");
  41. else {
  42.         actual.impValor();
  43.         aux.decValor();
  44.         recursion(aux);
  45.      }
  46. }
  47.  
  48. //Clase Main
  49. int main() {
  50. printf("Prueba de recursividad\n");
  51. printf("=======================\n\n");
  52. objeto miobjeto1(12);
  53. recursion (miobjeto1);
  54. return 0;}

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post