van posted:
Writing classes of some algorithms, some parameters needs to be passed
into the classes, the actual algorithms are contained in member
functions of classes.
What I am thinking is having some ordinary member variables as
parameters for algorithms, and member functions as "static".
Why are you going with "static" if you have ordinary member variables?
Since "static" member function cannot access ordinary member variables, it
is logic to make the latter as "static" as well.
I am very curious about how you'd like to design such kind of classes.
Thanks for your sharing!
Okkayyyyy... very little information, but I'll give it a go.
Let's say that the parameters for the algorithm are:
a string
a number
a boolean
So far we have:
class Ranger
{
public:
const char* name;
int id;
bool is_alive;
};
Now with some algorithmic functions:
class Ranger
{
public:
const char* name;
int id;
bool is_alive:
int WhatYearWasBorn();
unsigned char AmountOfChildren();
bool WillBeAliveTomorrow();
};
int main()
{
Ranger frankie;
frankie.name = "Francis Duffy";
frankie.id = 2256;
frankie.is_alive = true;
//Ofcourse you'd have a constructor for the above
//Now here comes algorithmic functions that work
//with the member data:
frankie.WhatYearWasBorn();
frankie.AmountOfChildren();
frankie.WillBeAliveTomorrow();
};
Did that clear anything up at all?
-JKop