|
-
December 4th, 2011, 12:54 PM
#1
Question about classes
This is just an idea that I am trying to think whether would make sense or not. I could simulate what I am thinking and prove myself but I am looking for some logic behind it as well.
So, I have lets say 20,000 rows of data and elements in each row refer to same variable i.e. price, date, time, quantity, etc.
I have two options with it:
Option 1:
Create one object have a matrix to store all the rows and have methods defined to do calculations like finding total quantity in a certain time period etc.
Option 2;
I create a class with members like price, data, time, quantity, etc. Then I create 20,000 instances of these objects and have functions to do calculations like finding total quantity in a certain time period by calling each object and getting it's time and quantity.
I think option 2 would be very slow as:
- 20,000 objects need to be created
- while getting quantity from each object i would need to have some sort of get function
- option 1 is also faster as i created only one object and everything is stored in one nice table and if I need a value I just need to do something like MyTable[i][j] where MyTable is a vector<vector>
Any thoughts?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|