Home > STL > Simple STL code in C++

Simple STL code in C++

Just a general simple program for the Standard Template Library (STL) List

#include <list>
#include <iostream>
using namespace std;
////////////////////////////////
class codeWord{
public:
double vl[3];
double minI;

codeWord(){
minI = 0;
vl[0]=vl[1]=vl[2] = 0;
};
};
////////////////////////////////
void printList(std::list<codeWord *> &ml){
cout <<endl;

codeWord *ptr;
for(std::list<codeWord *>::iterator list_iter = ml.begin(); list_iter != ml.end(); list_iter++)    {
ptr = *list_iter;
std::cout<<” ” << ptr->minI<<endl;
}

cout <<endl;

};
////////////////////////////////
void main(void){

std::list<codeWord *> mlist;
codeWord a;
codeWord b;

a.minI = 10;
b.minI = 5;

mlist.push_front(&a);
mlist.push_front(&b);

printList(mlist);

};

Advertisements
Categories: STL Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: