0

Specifics:

I'd like to have the following struct

struct edgeT {      
  string home;      
  string away;      
  int weight;  
};

And then have a priority queue of type edgeT.

I wrote a quick program to test the priority queue, but I'm getting the following error msg.

'Template argument for 'template class minPQ' uses local type 'Main()::edgeT'

I just defined/declared the struct at the start of the main() routine.

Does the struct have to be defined somewhere else?

hmjd
  • 120,187
  • 20
  • 207
  • 252
  • Can you show us how you're attempting to use `minPQ` and what line the error is on? – Joseph Mansfield Apr 04 '13 at 15:06
  • You are missing a strict weak ordering comparator for `edgeT`, but the error you quote points to another error. – juanchopanza Apr 04 '13 at 15:07
  • Move the definition of `edgeT` outside of `main` (it also looks like you may have named it incorrectly as `Main`, C++ is case-sensitive). Alternately, if you're using gcc, try compiling with the `-std=c++11` switch. – Praetorian Apr 04 '13 at 15:08

1 Answers1

1

Only since C++11 you can use types defined in functions as template arguments. Either use C+11, or put your struct definition at namespace scope.

PlasmaHH
  • 15,673
  • 5
  • 44
  • 57