Last change
on this file since 1571 was 1571, checked in by ansari, 24 years ago |
Compil avec SunOS-CC et ajout test vector,map de la STL (vecmapstl.cc) - Reza 12/7/2001
|
File size:
1.2 KB
|
Rev | Line | |
---|
[1571] | 1 | #include <stdlib.h>
|
---|
| 2 | #include <stdio.h>
|
---|
| 3 |
|
---|
| 4 | #include <exception>
|
---|
| 5 | #include <string>
|
---|
| 6 |
|
---|
| 7 | #include <iostream.h>
|
---|
| 8 | #include <vector>
|
---|
| 9 | #include <map>
|
---|
| 10 |
|
---|
| 11 | using namespace std;
|
---|
| 12 |
|
---|
| 13 |
|
---|
| 14 | int main(int narg, char *arg[])
|
---|
| 15 | {
|
---|
| 16 | cout << "\n ---- Test vector et map de la stl --- \n" ;
|
---|
| 17 | int rc = 0;
|
---|
| 18 | try {
|
---|
| 19 | vector<int> vi;
|
---|
| 20 | int k;
|
---|
| 21 | for(k=0; k<5; k++) vi.push_back(k*5);
|
---|
| 22 | cout << " vector<int> vi.size() = " << vi.size() << endl;
|
---|
| 23 | for(k=0; k<vi.size(); k++)
|
---|
| 24 | cout << "vi[" << k << "]= " << vi[k] << endl;
|
---|
| 25 | map<string, int> msi;
|
---|
| 26 | msi["Un"] = 1;
|
---|
| 27 | msi["Deux"] = 2;
|
---|
| 28 | msi["Cinq"] = 5;
|
---|
| 29 | msi["Douze"] = 12;
|
---|
| 30 | map<string, int>::iterator it;
|
---|
| 31 | cout << " map<string, int> msi.size() = " << msi.size() << endl;
|
---|
| 32 | for(it=msi.begin(); it!=msi.end(); it++)
|
---|
| 33 | cout << " S= " << (*it).first << " I=" << (*it).second << endl;
|
---|
| 34 | }
|
---|
| 35 | catch(exception exc){
|
---|
| 36 | // Classe de base des exception standard -
|
---|
| 37 | // La methode what() n'est pas forcement conforme a la norme
|
---|
| 38 | string msg = exc.what();
|
---|
| 39 | cerr << " Catched exception : msg= " << msg << endl;
|
---|
| 40 | rc = 98;
|
---|
| 41 | }
|
---|
| 42 | catch (...) {
|
---|
| 43 | cerr << " Catched Unknown exception ! " << endl;
|
---|
| 44 | rc = 99;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | cout << " ------ Exiting from vecmapstl.cc ----------- \n" << endl;
|
---|
| 48 | exit(rc);
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.