Hello,
I´m having problems with templates. I will explain my problem(sorry for my bad english).
I have a template like this:
template<TV,TR>
And a class by the name LISTA, so if a want to declare in main I do:
LISTA<int,int> graf;
But the problem is that I dont want int! I want that my TV be locals(city, village) and my TR be roads (freeways, national roads)..
I do I declare that?
LISTA< , > graf;
Thanks
But city, village, freeways and national roads are classes that inherit atributes from the main classes local and roads...
Can I do that?
Your template should work fine, do you get any error?
On main:
enum locais{
Cidade, Vila, LocalTuristico
};
enum vias_lig{
EstradaNacional, Autoestrada
};
ListAdjGrafo<locais,vias_lig> graf;
........
case 5:
graf.construir_grafo(graf);
system("pause");
break;
Then on the class ListAdjGrafo:
void ListAdjGrafo<TV,TR>::construir_grafo(ListAdjGrafo<locais,vias_lig> &graf) const{
.....
}
Error:
error C2664: 'ListAdjGrafo<TV,TR>::construir_grafo' : cannot convert parameter 1 from 'ListAdjGrafo<TV,TR>' to 'ListAdjGrafo<TV,TR> &'
On my computer it compiles fine...
Have you overloaded any constructor for your class?
Um... Why are you passing an object of type T to a method of class T? Don't you know about the this
pointer?