chronological arrangement

This is a discussion on chronological arrangement within the C++ Programming forums, part of the General Programming Boards category; I have a class that I can simply define as (I have simplified the class): Code: class Time{ public: Time(int ...

  1. #1
    Tweaking master Aslaville's Avatar
    Join Date
    Sep 2012
    Location
    Rogueport
    Posts
    107

    chronological arrangement

    I have a class that I can simply define as (I have simplified the class):
    Code:
    class Time{
    public:
    
    Time(int hour,int minute,int second):hour(hour),minute(minute),second(second){}
    
    private:
    
    int hour;
    
    int minute;
    
    int second;
    
    };
    Is it possible to check for chronological arrangement of two time objects most possibly without using an if statement ?
    Well this is off topic but there may be a python guru around,..is it possible to do similar thing in python?
    In C++14 you just write "auto auto(auto auto) { auto; }".
    The compiler infers the rest from context.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,648
    Huh, why would you not use an if statement, and what does this have to do with Python?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Tweaking master Aslaville's Avatar
    Join Date
    Sep 2012
    Location
    Rogueport
    Posts
    107
    Quote Originally Posted by laserlight View Post
    Huh, why would you not use an if statement
    I was just remembering having done it somwhere
    what does this have to do with Python?
    I thought that I could make the variables into a list for each object and compare the two lists.Python allows that ?

    I bet am just behaving like an idiot.
    Why not just convert everything to seconds and compare?
    In C++14 you just write "auto auto(auto auto) { auto; }".
    The compiler infers the rest from context.

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    make function getSeconds() for class

    And make a comparison function to return a difference of these 2 values. Looking at the sign of the difference you will know which object is "younger".

    No function will use an if... How you write the rest of the code without it... well, it's up to you.
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,302
    Yes it's possible, through various techniques, but that doesn't mean there's any reason to tell you about those ways since there is no good reason to use them.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  6. #6
    Tweaking master Aslaville's Avatar
    Join Date
    Sep 2012
    Location
    Rogueport
    Posts
    107
    Quote Originally Posted by iMalc View Post
    Yes it's possible, through various techniques, but that doesn't mean there's any reason to tell you about those ways since there is no good reason to use them.
    Give me a hint,..maybe I might need them in future.
    In C++14 you just write "auto auto(auto auto) { auto; }".
    The compiler infers the rest from context.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String array arrangement problem
    By Cheerio in forum C Programming
    Replies: 1
    Last Post: 05-02-2011, 07:40 PM
  2. arbitrary column arrangement of memory debug window?
    By m37h0d in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2009, 10:31 AM
  3. whats the best arrangement in writing to a FILE?
    By Huskar in forum C Programming
    Replies: 1
    Last Post: 03-30-2009, 07:12 AM
  4. arrangement of the string in every possible way
    By vijayr_singh in forum C Programming
    Replies: 2
    Last Post: 12-13-2006, 05:46 AM
  5. data arrangement and sorting.
    By cdkiller in forum C++ Programming
    Replies: 3
    Last Post: 02-15-2006, 12:55 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21