dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: typedef usage

  1. #1
    Join Date
    Jan 2008
    Posts
    60

    typedef usage

    typedef hash_map<int, list<string> > EXCEL_ROW;
    EXCEL_ROW row;
    why is typedef used here?

    couldn't i just say...
    hash_map<int, list<string> > row;

    Does it have any additional advantage to use the typedef method..
    Last edited by armen_shlang; April 1st, 2008 at 03:35 PM.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: typedef usage

    Quote Originally Posted by armen_shlang
    typedef hash_map<int, list<string> > EXCEL_ROW;
    EXCEL_ROW row;
    why is typedef used here?
    1) It is more easier to read,

    2) If you changed the typedef from hash_map to a std::map, you don't have to change all of your code also.

    3) it doesn't wear out your keyboard having to type

    "hash_map<int, list<string> >"

    all over the place.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Apr 2004
    Location
    England, Europe
    Posts
    2,492

    Re: typedef usage

    In addition to what Paul said ...

    Quote Originally Posted by armen_shlang
    couldn't i just say...
    hash_map<int, list<string> > row;
    string is a typedef, so you could also write:
    Code:
    hash_map<int, list<basic_string<char> > > row;
    As you can see, typedef makes it easier to read the code.
    My hobby projects:
    www.rclsoftware.org.uk

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)