Reputation: 1514
My topic question is a little misleading, I dont want to implement a whole class like a std::vector but I want to be able to create a class called Container so I can declare it like so:
Container <unsigned int> c;
So is this how I overload the <> operator...
class Container
{
private:
Container()
{
...
}
public:
void operator <>( unsigned int )
{
// what do I put here in the code?
// maybe I call the private constructor...
Container();
}
};
Upvotes: 0
Views: 145
Reputation: 3834
You should learn more about templates.
http://www.cplusplus.com/doc/tutorial/templates/
In a nutshell, what you want is:
template <class T>
class Container {
....
};
Upvotes: 1
Reputation: 272667
There is no operator <>
. The <>
denotes that Container
is a class template. You need syntax along the lines of:
template <typename T>
class Container
{
...
};
The best place to start is to find a good C++ book, but you could also try reading e.g. the C++ FAQ page about templates.
Upvotes: 7