title: How do I record a time in a constructor and how do I subtract the current time from construction in the destructor in a C++ Struct?
body: <p>I am currently working on an exercise in C++ where I am to create a struct called TimerClass whose constructor records the current time and and a destructor that records that current time and subtracts it from the time of construction (i.e. the current time in the constructor) and prints it to the console. Here is the code that I have so far:</p>
  
  <pre><code>#include &lt;cstdio&gt;
  #include &lt;cstring&gt;
  #include &lt;iostream&gt;
  #include &lt;chrono&gt;
  #include &lt;ctime&gt;
  
  struct TimerClass {
      TimerClass(time_t* timestamp) : timestamp(timestamp) {
          std::chrono::system_clock::now();
          printf("The current time is: %s\n", timestamp);
      }
  
      ~TimerClass() {
          printf("Time since last construction: %s\n", timestamp);
      }
  
  private:
      time_t* timestamp;
  };
  </code></pre>
  
  <p>I have tried looking up some possible solutions online without much luck. I am new to C++ and the book that I am learning from does not say how to record time.</p>