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,
struct mystruct{};
, the symbol followed by struct/class is not a
typename but a
tagname. So when someone writes:
1 2 3 4
|
typedef struct
{
///data
} custom_t;
|
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:
1 2 3 4 5 6 7
|
struct mystruct
{
/*data*/
};
int main(){
struct mystruct object; /*use a typedef to omit 'struct'*/
}
|
Luckily, in C++, (for better or for worse) you -can- use
tagnames as
typenames 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <list>
struct math_t /*using tagname as typename because in c++, I can*/
{
private:
//types
struct data_t
{
//data goes here
//data_t methods here
};
//data
std::list<data_t> data_pool;
//private methods here
void changeData(std::list<data_t>::iterator it);
public:
//public methods here
};
|