Originally Posted by
-EquinoX-
well it's a requirement for both the vector and the type parameter... I am only confused on how can I make so that whatever type is the parameters then it would support those operators
this compiles
Code:
#include <valarray>
int _tmain(int argc, _TCHAR* argv[])
{
std::valarray<std::string>thisMakesAtLeastSomeSense;
thisMakesNoSense+="asdf";
return 0;
}
because string has a += operator
this doesn't.
Code:
#include <valarray>
int _tmain(int argc, _TCHAR* argv[])
{
std::valarray<std::string>thisMakesNoSense;
thisMakesNoSense*="asdf";
return 0;
}
because string doesn't have a *= operator.
what you still don't realize is that even if you create a template class that has the operator in question, you can't guarantee you can use it.
you're transferring the inevitable compilation error from your vector class to your element class.