Thread: How do u control time in c++

  1. #16
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    >How do u control time in c++

    Example:
    Code:
    #include <timetravel.h>
    
    int main(void) {
      if((TimeMachine *tm = new TimeMachine("December 16, 2004"))) {
        tm->setYear(1942);
        delete tm;
      }
    
       return 0;
    }
    My sample code will take you back in time to World War II when compiled and executed. Compile and run this to get back:

    Example:
    Code:
    #include <timetravel.h>
    
    int main(void) {
      if((TimeMachine *tm = new TimeMachine("December 16, 1942"))) {
        tm->setYear(2004);
        delete tm;
      }
    
       return 0;
    }

  2. #17
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    you'll need to include <fluxcapacitor.h> to control time
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  3. #18
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    If misplaced is like me, I know the first thing on his/her mind was "man i wish i were the first to reply to this"

  4. #19
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    yup..i figured i'll join in the fun anyway
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  5. #20
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Fun is fun, but since we have both got crap in the past for someone taking us too seriously:

    DISCLAIMER: You cannot travel through time by including timetravel.h nor fluxcapcitor.h into your project. Cprogramming.com does not take responsibility for people lost in the space/time continueum from botched attempts at time travel using the C++ programming language.

  6. #21
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>delete tm;
    I'd just like to point out, this is an especially important line. You don't want to be losing your memory when you're faaaaar away from home.

    But if you do lose your memory and you can't handle life anymore, just run this:
    Code:
    delete this;
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  7. #22
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Quote Originally Posted by master5001
    >How do u control time in c++
    Code:
    #include <timetravel.h>
    
    int main(void) {
      if((TimeMachine *tm = new TimeMachine("December 16, 2004"))) {
        tm->setYear(1942);
        delete tm;
      }
    
       return 0;
    }
    Actually in this example once back in 1942 you don't need to worry about deleting the memory since its already freed and possibly non-existent.

  8. #23
    Registered User
    Join Date
    Dec 2004
    Location
    UK
    Posts
    109
    Of course you are all assuming that you'll find a computer in 1942 capable of running that program.

  9. #24
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I'm not, in my test program I reconfigured my cross compiler to compile the secondary program to punch card format. So I'll make it back just fine

  10. #25
    Registered User
    Join Date
    Dec 2004
    Location
    UK
    Posts
    109
    Quote Originally Posted by master5001
    I'm not, in my test program I reconfigured my cross compiler to compile the secondary program to punch card format. So I'll make it back just fine
    Good luck finding anything that resembles a computer in 1942, even one that reads punch cards. If I recall correctly the first computers where in 1943 and 1944 depending on the country (Germany, UK, USA) and 2 were definitely under constant surveillance by military personell (not quite sure about the z3 so your best bet would be to travel back around Berlin)

  11. #26
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Yeah, and also remember that the first computer used a vacuum cleaner motor for setting the CPU frequency...
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  12. #27
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Then I guess i better do this:

    Example:
    Code:
    tm->setPersonalItem("computer");

  13. #28
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Good idea. Don't forget that this overrides the default choice ("clothes"). TimeMachine can only handle one personal item.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  14. #29
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    lmao! Well like any programmer I'm not afraid to toy with the rules to get what I want.

    Example:
    Code:
    tm->setPersonalItem("computer,clothes,book on WWII German war strategies");

  15. #30
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Yeah, well, just beware, because most implementations I know have undefined behaviour on that. And undefined behaviour is something you don't want while time-travelling
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. last write time
    By pastitprogram in forum C++ Programming
    Replies: 2
    Last Post: 07-31-2008, 06:54 PM
  2. (Multiline) Edit Control Limit
    By P4R4N01D in forum Windows Programming
    Replies: 9
    Last Post: 05-17-2008, 11:56 AM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  4. Read and set\change system time
    By Hexxx in forum C++ Programming
    Replies: 9
    Last Post: 01-02-2006, 07:11 AM
  5. calculating user time and time elapsed
    By Neildadon in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2003, 06:00 PM