Thread: Why this is legal to write uint_64(x)?

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    284

    Why this is legal to write uint_64(x)?

    Code:
    typedef uint_64 Time;
    
    Time x = 123;
    Time y = Time(x);
    The second line looks like a constructor! But Time is nothing more than a build-in type. Is this legal and why?

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    it's perfectly legal - but just remember that the ctor for built-in types must be called explicitly. in other words:

    Code:
    char c; // uninitialized - contains junk.
    int i = int(); // initialized to 0.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how could i write this program: cat < apa | wc | wc > bepa
    By strugglingman in forum C Programming
    Replies: 2
    Last Post: 04-26-2006, 04:40 PM
  2. Replies: 5
    Last Post: 03-18-2006, 11:25 AM
  3. program to make a floppy write protected
    By shrijeetp in forum C Programming
    Replies: 1
    Last Post: 10-03-2005, 06:00 AM
  4. Reroute where programs write to
    By willc0de4food in forum C Programming
    Replies: 7
    Last Post: 09-21-2005, 04:48 PM
  5. Function to write string 3 times
    By Giggs in forum C++ Programming
    Replies: 15
    Last Post: 12-24-2002, 04:00 PM