std::string makes programming more convienent to write, but is not faster than an old-fashioned pointer to char. Normally direct manipulations of (char * ) are faster, but more diffucult to handle (memory leaks, allocation, free etc. pp.). Perhaps anyone can correct my: But so far I know the most std::string impementations use in the background the still (char *).
Of course it possible to transform a function of the type
a_n+1:= f (a_n)
into
a_n:= g (a_0, n)
This is not the question. By using a recursion the problem is: Does it makes sense: How much Stack I will need in worst case scenario? How much the calls, pops and pushs will effect the performance? Is it worth to pay this prize? Often enough I would say: Yes, but not always.
The "self-calculations" has an other benefit: If have class (template) administrating such a multi-dimensional array, the access calculation method can include checks against dynamical boundaries violations which can produce an error message/exception etc. - A very usefull "side-effect"
I had only a brief in the handling of the example code for matrix.cpp file. This code a fine example to slower the performance of code. It is always a bad idea to handle a matrix as a two-dimensional array. Doing so will cause the processor to performe complex calcumaltion of the size of the object. Any experienced coder would use a simple array and small method to calulate the position Something like
return (iPos_x + iPos_y * iCount_x)
I must support Pascal as a first programming language. Honestly: My C++ still looks a lot like Pascal... Also: Pascal restricts the worst things to do and has a strikt type check - always a benefit.
std::string makes programming more convienent to write, but is not faster than an old-fashioned pointer to char. Normally direct manipulations of (char * ) are faster, but more diffucult to handle (memory leaks, allocation, free etc. pp.).
Perhaps anyone can correct my: But so far I know the most std::string impementations use in the background the still (char *).
Of course it possible to transform a function of the type
:= f (a_n)
into
a_n := g (a_0, n)
This is not the question. By using a recursion the problem is: Does it makes sense: How much Stack I will need in worst case scenario? How much the calls, pops and pushs will effect the performance? Is it worth to pay this prize? Often enough I would say: Yes, but not always.
a_n+1
The "self-calculations" has an other benefit: If have class (template) administrating such a multi-dimensional array, the access calculation method can include checks against dynamical boundaries violations which can produce an error message/exception etc. - A very usefull "side-effect"
They shall/should, but you can not be sure - therefore it just better to make it on your own
I had only a brief in the handling of the example code for matrix.cpp file. This code a fine example to slower the performance of code. It is always a bad idea to handle a matrix as a two-dimensional array. Doing so will cause the processor to performe complex calcumaltion of the size of the object. Any experienced coder would use a simple array and small method to calulate the position Something like
return (iPos_x + iPos_y * iCount_x)
I must support Pascal as a first programming language. Honestly: My C++ still looks a lot like Pascal ... Also: Pascal restricts the worst things to do and has a strikt type check - always a benefit.