Convert VisualC++ template to gcc
Hello,
trying to get some code converted from Visual C++ 6 to gcc.
I've got pretty far, but as a C++ newbie I'm little bit lost with templates.
It would be very nice if somebody could help me to get this working (with
explanation please so I can learn).
A possibility would also be to convert this template to a normal function
(if it would help to get this working)
Here is the template (table.h):
Code:
#ifndef _TABLE_H
#define _TABLE_H
#include <string>
#include <vector>
using namespace std;
template <class T>
class table: public vector<T>
{
public:
T operator[] (const string& key);
};
template <class T>
T table<T>::operator[] (const string& key)
{
for (reverse_iterator i = rbegin(); i != rend(); i++)
if (*i)
if ((*i)->name ^ key)
return (T)((**i)());
throw out_of_range("no elements matching key");
}
#endif
Thanks in advance
efgee