<div dir="ltr">hi<br><br>i am compiling the following code:<br><br>1:#include <map><br>2:<br>3:template <class a, class b><br>4:class c<br>5:{<br>6: private:<br>7: b defaultVal;<br>8: public:<br>
9: std::map<a,b> mymap;<br>10: const b &func(a idx)<br>11: {<br>12: std::map<a,b>::iterator it=mymap.find(a);<br>13: if (it!=mymap.end())<br>
14: return it->second;<br>15: else<br>16: return defaultVal;<br>17: }<br>18:};<br>...<br>...<br><br>compiling it (under cygwin) , i get the following:<br>
<br>$ g++ -c -o kaka.o kaka.cpp<br>kaka.cpp: In member function 'const b& c<a, b>::func(a)':<br>kaka.cpp:12: error: expected `;' before 'it'<br>kaka.cpp:13: error: 'it' was not declared in this scope<br>
<br><br>what's wrong ?<br></div>