Hi everybody,
the mfribeiro-code could (should?) be improved by avoiding the
defines, and by avoiding any need to delete pointers
if the array a is to be used in a body of a function other than main:
#include <vector>
void test(void){
using std::vector;
int lin=3, col=5;
vector<vector<double> > a(lin,vector<double>(col));
a[2][4]=123.4;
cout<<"a[2][4]="<<a[2][4]<<", should be 123.4"<<endl;
}
No need for doing arithmetics for accessing the entries to doubled indexed
structure.
Who has to work a lot with multi-indexed structures, better defines classes
for those, or gets the stuff from the boost library.
Regards
Ulrich
|