My problem is not serious,
its just a question about the most beautifull solution.
Maybe somebody has a better idea!
I have a mathematical class having some numerical functions.
It is convenient for me, and speed up the program,
if I introduce a member array called "memory",
and store the values of the previous calling.
(for example Maple can do the same)
Before this solution my function has the const qualifier,
but now it cannot be const, because I write in the memory.
Its ok for a programmer,
but its not logical to a mathematician,
since I only get values with the calling of that function.
If I use my class as a member in another class,
I cannot call the non const function from another const function,
which is inconvenient also.
An other solution is to use global memory variables,
but I have not just one object from the same class,
so I cannot use the same global variable.
Therefore this solution is dirty also. Any idea? Thanks
Recommended Answers
Jump to PostI would question how you are using the vector to store the results. How will you differentiate between results from different functions, or worst results from different functions that take different numbers of parameters?
Anyway your storage scheme aside I see 2 possible solutions. You could declare memory mutable. …
Jump to Postconst is a some what overrated concept that leads to more typing
and maintenance.In your case myfunc is not const as it alters a member variable
if this is not appropriate to be altered then you need to use a localdouble myfunc(double x1,double x2, double x3) …
Jump to Post
I wonder did you read the previous posts at all?Yes. Yet again you are jumping on a single sentence and basing your entire response on that basis.
I have several maths functions and if you are encapsulating them in a class rather than global functions you would …
Jump to PostYes. Yet again you are jumping on a single sentence and basing your entire response on that basis.
I have several maths functions and if you are encapsulating them in a class rather than global functions you would get something like:
#include "../my_maths/my_maths_functions.h" double my_class::my_function(const double x1, const …
All 14 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.