I am pretty much a relative beginner in coding doing Mech Engineering, with no advanced knowledge about pointers and stuff, basically using learncpp.com on half a screen, and the IDE on the other half, so please bear with my 'novicity'/'noviceness'.
I am using dynamic memory allocation using std::vector, and am trying to understand if I can call a function as a parameter to another function the way I will tell you below. I did research on this, and the closest answer I could find is here: Using a function as a parameter to another function, but for some reason I am unable to connect my problem with the answer to his problem, and this is the closest answer I could find between many sites I follow, so there is that. I am not even sure of what exactly is it that I am doing, so putting it in words is tough for me.
okay so if I want to do a1*((a+b)/(a-b)) "everything element wise, everything a 2D vector"
the normal way to do it would be(vecd2 is a typedef of 2D vector)
vecd2 sumew,subew,divew,ans,a,b;
loop
sumew=a+b
loop end
loop
subew=a-b
loop end
loop
divew=sumew/subew
loop end
loop
ans=a1*divew
loop end
now, say I have created functions for a+b, called sum, a-b, called sub, a*b, called mult, and a/b, called div
then is it possible to get the same answer as above using
vecd2 ans=mult(a1,div(sum(a,b),sub(a,b)))
The individual functions have the loops in them properly.
I know matlab does them, but I don't know if c++ has the same functionality as matlab here.
I am not keen on using add-on C++ libraries. I want this done in pure C++11 code.
EDIT: I am planning on learning pointers, I know they are important, but if it is possible for me to do things without them, I would rather do them so. I plan on learning and implementing pointers later, once I am more confident in the way I handle more basic C++ coding. If it is absolutely not possible without pointers, lead on!