Template copy constructor

I have HashTable& operator=(const HashTable& aTable);

1
2
3
4
5
6
template <typename HashElement>
HashTable& HashTable<HashElement>::operator=(const HashTable& aTable)
{
/*Do the copy thing*/
 return *this;
}


It should be a run-able function in my opinion

1
2
3
HashTable<EngWord> hashTable;
HashTable<EngWord> hashTableA;
hashTableA = hashTable;

But it dosn't like the

**HashTable&** HashTable<HashElement>::operator=(const HashTable& aTable)
The error messages is "HashTable: super of class template requires template argument list and HashTable<HashElement>::operation=':unable to match function definition to an existing declaration

On what I've seen on the internet it should be the way I've written
Last edited on
You parameter aTable on line 2 of the operator=() is a HashTable... but a HashTable of what? You haven't specified.
But the HashTable is a template and will be EngWord, as HashTable<EngWord> hashTable;
The template argument is not implicit for the return type when defining it outside the class template definition.
1
2
3
4
5
6
template <typename HashElement>
HashTable<HashElement>& HashTable<HashElement>::operator=(const HashTable& aTable)
{
/*Do the copy thing*/
 return *this;
}
Topic archived. No new replies allowed.