I am designing something to do operatorations from an expression, so for example (3 + 5), the string would be read and the expression will be evaluted and returned. Now I got the correct output, my problem is that I implemented the stack in three different ways, linked list, Vector, and dynamic array, now they all have the same method names, push and pop respectivity just different implementation. Now I got a function for each of them so that I got:
void doVectorOp(V_H<int> value, V_H<char> op){//my personal vector class for stack
//do something
}
void doDynamicOp(D_H<int> value, D_H<char> op){
//do something
}
void doLinkedOp(SLL<int> value, SLL<char> op){
//do something
}
Now the three functions have the exact same code and do the same thing, but with different class types, can I reduce all these functions into one. Something like:
void doOp(Generic class<int> value, Generic class<char> op){
//do something
}
thanks, Yun Fei Chen
Aucun commentaire:
Enregistrer un commentaire