setting up a simple template...
I am stumped on a simple template problem
I copied this code from a book word for word and the code doesn't work. I wonder if there is a typo in the book or maybe I am stupid and missed something but heres the code:
----------------------------------------------------------------------------
#include <set>
#include <iostream>
using namespace std;
template <typename Container>
void displaySet(const Container & input);
int main (int argc, char * const argv[])
{
return 0;
}
template <typename Container>
void displaySet(const Container & input)
{
Container::const_iterator iElement;
//RIGHT HERE I GET (error: expected ";" before 'iElement')
}
------------------------------------------------------------------------------
Re: setting up a simple template...
Ah, the discrepancies between compilers! Microsoft's compiler would happily compile your code but gcc is more conforming to the standard. The Fix:
Code:
template <typename Container>
void displaySet(const Container & input)
{
typename Container::const_iterator iElement;
}
Re: setting up a simple template...
Wow that worked.
Thanks angelorohit.
I use Xcode for compiling is there a site that you might recommend for me to find these differences so that I won't have to bug anyone for small things like this?