SHARE
TWEET

temp c++

a guest Oct 21st, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Datum.h
  2.  
  3. #ifndef DATUM_H
  4. #define DATUM_H
  5. #include <cstdlib>
  6. #include <iostream>
  7.  
  8. using namespace std;
  9.  
  10. class Datum
  11. {
  12.     public:
  13.         Datum();
  14.         Datum(float);
  15.         Datum(const Datum &);
  16.         //~Datum();
  17.         void setData(float);
  18.         float getData();
  19.     //private:
  20.         float data;
  21.         Datum *next;
  22. };
  23.  
  24. #endif
  25.  
  26. Datum.cpp
  27. #include "Datum.h"
  28. #include <iostream>
  29. #include <cstdlib>
  30.  
  31. using namespace std;
  32.  
  33. Datum::Datum()
  34. {
  35.    data = 0;
  36.    next = NULL;
  37. }
  38.  
  39. Datum::Datum(float input)
  40. {
  41.     data = input;
  42. }
  43.  
  44. //Copy constructor issue, ask Valafar
  45. Datum::Datum(const Datum &rhs)
  46. {
  47.     data = rhs.data;
  48. }
  49.  
  50. void Datum::setData(float input)
  51. {
  52.     data = input;
  53. }
  54.  
  55. float Datum::getData()
  56. {
  57.     cout << data;
  58. }
  59.  
  60. main.cpp
  61.  
  62. #include "Datum.h"
  63. #include <iostream>
  64. using namespace std;
  65.  
  66. int main(int argc, char** argv)
  67. {
  68.   Datum a(1);
  69.   Datum b(2);
  70.   a.data = 3;
  71.   //a.next = &b;
  72.  
  73.   cout << &a << endl;
  74.   cout << &b << endl;
  75.  
  76.   cout << a.next << endl;
  77. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top