CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2006
    Posts
    141

    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
    Join Date
    May 2006
    Location
    Norway
    Posts
    1,709

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

    if uint_64 is a valid typedef then the code is legal.

    You are only assigning the value of x to y (you are also doing an unecessary explicit cast).

    It is just like writing:
    Code:
    int x = 123;
    int y = x;
    Laitinen

  3. #3
    Join Date
    Feb 2005
    Location
    "The Capital"
    Posts
    5,306

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

    This is legal although it does not mean those types have a constructor. This syntax helps in template metaprogramming.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured