Best way to have a static std::string (array?)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Best way to have a static std::string (array?)

  1. #1
    Join Date
    Aug 2009
    Posts
    219

    Best way to have a static std::string (array?)

    Hello,

    I've got a class, which reads data from a external program. It has to compare these values each time with a array of std::strings. What would be the best way to declare and compare this?

    a Vector for std::string or a list. Some Boost:: library option?

    Small exmaple,

    Program recieves value 1990->in string -> compare with a static std::string

    The static std::string array will be filled with user input from the GUI.

    Thanks a lot.

    NM

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Best way to have a static std::string (array?)

    Compare for what reason? Just to see if the string is in the list? If so, I'd store them all in a set.

    Viggy

  3. #3
    Join Date
    Aug 2009
    Posts
    219

    Re: Best way to have a static std::string (array?)

    Quote Originally Posted by MrViggy View Post
    Compare for what reason? Just to see if the string is in the list? If so, I'd store them all in a set.

    Viggy
    Yes the value I recieve to compare with the strings in the array/list/vecotr. Why a set?

  4. #4
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,891

    Re: Best way to have a static std::string (array?)

    A set is going to be more efficient to search than a list or vector. This might not make much difference if you only have a few things to test against though.

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

This is a CodeGuru survey question.


Featured


HTML5 Development Center