hi, 

can anybody help with this ...

i have a class holding some statistics ....

class Stat{
        int count1;
        int count2;
}

i have two classes with class Stat embedded ..

class A{
        Stat stats[10];
        
        ....
}

class B{
        Stat stats[10];

        ....
}

both of these are encpsulated in another class ...

class C{
        A x[n];
        B y[m];

        ...
}

and now, for some k, i would like to be able to print the contents
for all j, of

x[k].stats[j, j=0..9].count1 // or count2
y[k].stats[j, j=0..9].count1 // or count2


one solution i came up with was to define template functions ....

template <class T>
printCount1(T& zz, int i){
        for(int j=0;j<i;j++){
                zz.stats[j].count1;
        }
}

template <class T>
printCount2(T& zz, int i){
        for(int j=0;j<i;j++){
                zz.stats[j].count2;
        }
}

obviously if i was a resonable guy, i would stop at this point and say
it was enough. but as you might have guessed, i am not. i want to
further abstract this into something like 

monitor(char *msg, <pointer to template function>){
        // so i can go 
        cout << msg;
        call template function;
        cout << endl;
}

i am out of my depth here, and would appreciate any help that can be
provided. thanks in advance.

-shishir



 Shishir Ramam
 Graduate Student,
 Computer Science and Telecommunications Program,
 University of Missouri - Kansas City,
 Kansas City Mo
 e-mail : [EMAIL PROTECTED]

Reply via email to