Solved

calculate a reference key with parameters of 0-99 (100 entries max)

Posted on 2004-08-14
3
190 Views
Last Modified: 2010-04-01
Hi,

I am needing some advice on how to calculate a reference key.  The function I have is
int getReferenceKey(int key)
the value of the key is calculated by the formula
key=(location index)*10+(type index.)

thanks.

Kaz
0
Comment
Question by:KazIT
  • 2
3 Comments
 
LVL 19

Expert Comment

by:mrwad99
ID: 11799399
Kaz

Can you clarify exactly what you are after please as it is not quite clear.

Cheers
0
 

Author Comment

by:KazIT
ID: 11803051
The program I am constructing will have up to 100 entries, consisting of say 6 columns of information.  Each line of each entry needs to have a reference key assigned to it.
0
 
LVL 19

Accepted Solution

by:
mrwad99 earned 500 total points
ID: 11803566
So just make some formula up and get a value from that.  You are already doing something like this according to your first post; simply chose another formula that generates a unique value.

If you have 100 entries, numbered 1-100 or 0 - 99, and six columns, numbered 1 - 6 or 0 -5, then a reference key could be entry * column with a little more 'spice' added to it.  Alternatively you could always use the address of each entry, that is guaranteed to be unique.

HTH
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
c++ mixing int and strings in multi array 8 71
Handle Exceptions during instantiation 28 411
Find Visual Studio Tools 2 92
I could not build boost code, 10 78
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now