There is a small problem in teh way you've used structure and arrays concepts. Better way of doing this would be to have a struct with 3 members and then use an array of struct. (instead of having arrays as members of the struct)
Like this:
struct Tender {
int tenderType;
int tenderAmt;
int tenderRiskLvl;
}tenderVariableArray[5];
A better usecase for using std::map is when you have to associate a value with a key (e.g. "name of student" is the key and "his marks in all exams" is the value).
For your problem in general I would recomment you try with vector instead of map.
In general for STL Map Intro you can see this and this . You should find things on vector as well in same links.
If you want to try out map check this may be there is a problem more suitable for usage of map.
thekashyap
Practically a Posting Shark
811 posts since Feb 2007
Reputation Points: 254
Solved Threads: 75
I was in an assumption its actually two ways of implementing it. Has it got something to do with the way how the memory been allocated? Thanks
Indeed what you've done and what I suggested are 2 diff ways of doing the same thing.
No it has nothing to do with memory allocation. Both use same amount of memory. The memory layout will be different though.Meanwhile, could you please tell me what is the significance of using array of members and array of struct.
Like I said these are 2 ways of solving same problem. But as they teach in classroom abt OOAD, first thing you do is read the problem statement like a story and underline the words you think are objects. These become your classes (or structures). If you go this way Tender is one such word so you'll make a class or a struct out of it.
Now when you have a struct to represent a Tender, you can do it in 2 ways. But in your way (read this literally not technically) "ONE object of Tender does NOT represent ONE Tender". In my way it does.
So my way makes things easier to work with, understandable...
thekashyap
Practically a Posting Shark
811 posts since Feb 2007
Reputation Points: 254
Solved Threads: 75