Advertisement
Guest User

Untitled

a guest
Jun 28th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. En ClasePrueba.cpp:
  2. #include "ClasePrueba.h"
  3.  
  4. //Constructor
  5. TClase::TClase()
  6. {
  7.         Int = new TInt();
  8. }
  9.  
  10. //Destructor
  11. TClase::~TClase()
  12. {
  13.         delete Int;
  14. }
  15.  
  16. //Constructor
  17. TInt::TInt()
  18. {
  19.         valor = &TClase::I;
  20. }
  21.  
  22. //Destructor
  23. TInt::~TInt()
  24. {
  25.  
  26. }
  27.  
  28. //Metodo de la clase
  29. AnsiString __fastcall TInt::toHex(int value)
  30. {
  31.         *valor = value;
  32.         return AnsiString().sprintf("0x%s",AnsiString().IntToHex(*valor ,8));
  33. }
  34.  
  35. En ClasePrueba.h:
  36. class TInt
  37. {
  38.         public:
  39.         TInt();
  40.         ~TInt();
  41.         AnsiString __fastcall toHex(int value);
  42.  
  43.         private:
  44.                 int TClase::*valor;
  45. };
  46.  
  47. class TClase
  48. {
  49.         friend class TInt;
  50.  
  51.         private:
  52.                  int I; //Variable privada
  53.  
  54.         public:
  55.                 TClase();
  56.                 ~TClase();
  57.  
  58.                 TInt *Int;
  59. };
  60.  
  61. //---------------------------------------------------------------------------
  62. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement