Thread: Need Advice

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    80

    Need Advice

    I'm using Visual Studio 2005 to convert old Fortran code to C++.

    I'm still pretty new to C++ and was a Web Developer specializing in
    Coldfusion previously. Coldfusion doesn't worry about type, so arrays
    are simple.

    I have some code that contains a list of 500 chemical fragments along with an associated value that needs to be accounted for if the specific fragment is found in a chemical. This list gets searched multiple times in the program. A specific fragment may be found in two places so I need to track the number of times each fragment is found.

    In coldfusion I would set up an array named Fragments. This would consist of a FragID (int) Fragment (string) value (double) and NumFound (int). I know
    C++ arrays need to be of the same type. I've looked at possibly using std::map and have been trying to think of alternative ways to handle this.

    Does anyone have any advice or best practice regarding on how I should go about coding this?

    Thanks

    James

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    I'm not sure I see where you think you need an array of different types. That sounds like it should be a structure, not an array. You could make a Fragment class that holds that data, then an array of that class. A map or set of that class could also work.

    Based on my understanding of your problem, I would create a std::set of the Fragment class, and make an operator< for it that compares by FragID so you can look up the fragment easily.

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    80
    Thanks David, I'll try that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Advice on C Programming with MSVC++ 2008
    By IT_Guy in forum Windows Programming
    Replies: 1
    Last Post: 03-06-2009, 04:23 AM
  2. girl friend advice (prob. the wrong place)
    By B0bDole in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 10-22-2004, 06:38 PM
  3. need advice on project
    By lambs4 in forum C Programming
    Replies: 2
    Last Post: 07-23-2003, 01:06 PM
  4. need hardware advice....
    By forgottenPWord in forum Tech Board
    Replies: 5
    Last Post: 03-23-2003, 09:12 AM
  5. Newbie: Seek advice
    By gogo in forum C++ Programming
    Replies: 4
    Last Post: 11-06-2001, 10:04 AM