From a57a70eab1f0b259f3b488a58e1812b262455b33 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Mon, 12 Sep 2005 18:29:39 +0000 Subject: [PATCH] Agrego constructores --- src/clave_fija.cpp | 14 ++++++++++++-- src/clave_fija.h | 6 ++++-- src/main.cpp | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/clave_fija.cpp b/src/clave_fija.cpp index 05c9814..a954e24 100644 --- a/src/clave_fija.cpp +++ b/src/clave_fija.cpp @@ -2,12 +2,22 @@ #include #include "clave_fija.h" -uint ClaveFija::Size () +ClaveFija::ClaveFija (int n) +{ + data = n; +} + +ClaveFija::ClaveFija (uchar *n) +{ + memcpy (&data, n, sizeof(int)); +} + +uint ClaveFija::Size () const { return sizeof (int); } -uchar *ClaveFija::ToArray () +uchar *ClaveFija::ToArray () const { uchar *out; out = new uchar[sizeof(int)]; diff --git a/src/clave_fija.h b/src/clave_fija.h index f092250..aa6e712 100644 --- a/src/clave_fija.h +++ b/src/clave_fija.h @@ -6,10 +6,12 @@ class ClaveFija : public Clave { public : + ClaveFija (uchar *n); + ClaveFija (int n); virtual ~ClaveFija () {} - virtual uint Size (); - virtual uchar *ToArray (); + uint Size () const; + uchar *ToArray () const; private: int data; diff --git a/src/main.cpp b/src/main.cpp index b41152b..c22dde9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,7 +6,7 @@ int main (int argc, char *argv[]) { BTree *tree; - ClaveFija c; + ClaveFija c(5); tree = new BTree ("test.idx", 1024); -- 2.43.0