Welcome! Log In Create A New Profile

Advanced

sequences

Posted by chaospixel 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
sequences
April 18, 2006 10:35PM
has anyone figured out how to put data into a sequence?

I see two options:
* initialize the sequence to the desired size and use operator[] to assign individual values
* or copy all the data you want into an array of objects and pass a reference to that pointer to the sequence constructor

I've tried the first approach, but I can't figure out what type operator[] expects for assignment.

Can anyone help with this?
Re: sequences
April 19, 2006 08:59AM
I haven't tried to do this yet. Re your question, would you not use pointers to objects? Another avenue to explore is, I remember from COS211 (data structures) that the textbook has a whole section on overloading operator[]. If you still have the 211 text book, you should find code snippets there.
Re: sequences
April 19, 2006 10:44AM
Hi there,

well first you need to decide which sequence conatiner you are willing to use.

The STL provides programmers with the following artifacts, grouped into three categories:

* Sequences
o C++ Vectors
o C++ Lists
o C++ Double-Ended Queues
* Container Adapters
o C++ Stacks
o C++ Queues
o C++ Priority Queues
* Associative Containers
o C++ Bitsets
o C++ Maps
o C++ Multimaps
o C++ Sets
o C++ Multisets

A great reference site is

http://www.sgi.com/tech/stl/

In order to insert elements into sequences in most you use the following methods:

void push_front(const T&winking smiley Inserts a new element at the beginning.
void push_back(const T&winking smiley Inserts a new element at the end.

I assume you want to fill your container with the currencies and their conversion factors.

Why don't you use maps to store your conversion factors?

For example:

map<const char*,map<const char*,double> > mConversionFactors;


Cheers

Dariusz




Sorry, only registered users may post in this forum.

Click here to login