what is the best data structure in this case? [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
what is the best data structure in this case? I am using c++. yes I am a newbie.
Function getValues
Inputs:
ID // string
StatType // enum
Output:
value // double
There is a bunch of data which can be organized as a two dimensional array. The function should check the ID and the stat Type and return the appropriate value.

This appears to be a specification for a function, not a data structure. The function declaration would look something like this:
enum enumtype { ... };
double getValues(std::string ID, enumtype StatType);

Related

c++ conversion const member [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a member L that is a list of pairs of ints which I would like to use in a const function. I'm hence not supposed to modify L, but I don't know how I can iterate through L, to read its contents (as opposed to modifying them).
The compiler keeps saying there is a conversion issue.
Assuming you are using std::list<std::pair<int,int>> you need to use std::list<std::pair<int,int>>::const_iterator as the type for your iterator.

What is the boolean data type in C++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I'm doing some exercise where I need to use a boolean. However when I try to create one as Boolean the compiler does not accept it. What is the name of the boolean type in C++?
The boolean datatype in C++ is bool as in:
bool myBool = true;

about pointer and reference [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a pointer *p and a reference &s. I would like all the values that s contains to be copied by p. How can I do this?
Need some code example. THX
Your question is a lot less than clear. But for now, I'll give you this:
*p = s;
If this doesn't answer your question, then you need to clarify exactly what you're after.

what's the type of 'struct random_data* buf'? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I'd like to have an instance variable of "struct random_data*" which are used in
int random_r(struct random_data *buf, int32_t *result);
I've tried declaring as
"struct random_data* instanceBuf;"
"random_data* instanceBuf;"
but compiler doesn't like any of it.
How should I declare the variable?
-Edit
ah,, the api is for linux, and i'm on mac(bsd) :(
Oh wait, is it really linux only?
http://www.gnu.org/s/libc/manual/html_node/BSD-Random.html
Probably:
struct random_data buff;
int x = random_r (&buff, ...);
is the easiest solution. But you'll have to make sure that that structure has been defined.
And, if the buffer is required to be long lived (like a seed), make sure it's defined somewhere with a large scope (global or class-level, for example).

validating the value in a integer...? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
how do v find a value in an integer is garbage or not???
Initialize it at point of declaration, and it can never be garbage.
Pass it to strfry and compare the returned value with the original.
I guess that you mean if a string contains a valid integer. Check out scanf or the stream equivalent of c++, or Boost lexical cast