But when I turn this class to template class things goes bad ,can you tell me why please?
It helps if you're more specific. "Things go bad" or "it doesn't work" doesn't really give us any indication of what the problem is. Is it a compiler error? What are the errors? Does it compile but crash when you run it?
The only thing I can see that's wrong is this:
1 2 3
map<int,int>::iterator iter; // <- your iter is map<int,int>
for(iter = classMap.begin() ;iter != classMap.end() ;iter++)
You don't want map<int,int>::iterator here... you'd want map<T,T2>::iterator. Or better yet, just use auto:
1 2 3
// map<int,int>::iterator iter; // <- get rid of this. Add auto to below
for(auto iter = classMap.begin() ;iter != classMap.end() ;iter++)
Thanks for reading and, I am sorry to give such a bad specification, I mean by "Things go bad" that it does not compile with these errors in code::blocks
C:\Documents and Settings\Techno01\Bureau\myProject\main.cpp|35|error: missing template arguments before 'firstC'|
C:\Documents and Settings\Techno01\Bureau\myProject\main.cpp|35|error: expected ';' before 'firstC'|
C:\Documents and Settings\Techno01\Bureau\myProject\main.cpp|36|error: 'firstC' was not declared in this scope|
what I am trying to do is to pass my myMap container ,but It seems that the compiler wants me to set aguments or something
also my compiler does not support c++11 to use auto(I think)