Why this is legal to write uint_64(x)?

This is a discussion on Why this is legal to write uint_64(x)? within the C++ Programming forums, part of the General Programming Boards category; Code: typedef uint_64 Time; Time x = 123; Time y = Time(x); The second line looks like a constructor! But ...

  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,700
    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:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(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, 10: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, 03:00 PM

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