For the time being, I'm a bit busy. I've skimmed through your code though, and might come back to look at it more in-depth.
Here's a few things I noticed.
Your use of typedef
is improper. You may want to look into typedef
, which C++ inherited from C. When you declare a struct or class,
, the symbol followed by struct/class is not a typename
but a tagname
. So when someone writes:
They declare an anonymous struct
of type custom_t. This way, the tediousness of declaring structs as types using the struct
keyword like the following can be omitted:
struct mystruct object; /*use a typedef to omit 'struct'*/
Luckily, in C++, (for better or for worse) you -can- use tagnames
and omit the struct
keyword in type declaration either way.
Another thing I noticed is that you're using new
in your code. This is very error-prone, and should be avoided when possible.
Instead, try using a standard template library container
to manage dynamic memory for you.
Another thing you may want to look at is encapsulation to organize code a little better.
Here's a prototype.
struct math_t /*using tagname as typename because in c++, I can*/
//data goes here
//data_t methods here
//private methods here
void changeData(std::list<data_t>::iterator it);
//public methods here