I have a function:
template<typename containerT>
void incElement(containerT c){
for(auto i = c.begin(); i != c.end(); ++i) {
for(auto j = (*i).begin(); j != (*i).end(); ++j) {
++(*j);
}
}
}
How can I make this work with C ++ 98? I tried:
template<typename containerT, typename containerRowT, typename containerElementT>
void incElement(containerT<containerRowT<containerElementT> > c) {
for(containerT<containerRowT<containerElementT> >::iterator i = c.begin(); i != c.end; ++i) {
for(containerRowT<containerElementT> >::iterator j = (*i).begin(); j != (*j).end(); ++j){
++(*j);
}
}
}
And this does not work and gives me an error, for example:
test.cpp:4:17: error: ‘containerT’ is not a template
void incElement(containerT<containerRowT<containerElementT> > c) {
^
test.cpp:4:28: error: ‘containerRowT’ is not a template
void incElement(containerT<containerRowT<containerElementT> > c) {
^
test.cpp: In function ‘void incElement(containerT)’:
test.cpp:5:7: error: ‘containerT’ is not a template
and etc.
How can i do this?
source
share