I need to pass a non-static data member in one class (class Disks, data member disks) to another class (ToH) to its static bool function, so I can test that value.
In that case, modify the ToH::test()
to take as an argument a variable of type Disks
, i.e.
bool ToH::test(Disks & obj)
// or maybe ...
// bool ToH::test([B]const [/B]Disks & obj)
{
bool answer;
// if disks is a private/protected member, you might change it to public
// or make ToH friend of Disks or add a method e.g. GetDisks().
if(obj.disks == 1)
...
}
// and used like
int main()
{
Disks obj(3);
bool b = ToH::test(obj);
...
}
or pass just the value of disks, so it would be
bool ToH::test(const int disks)
{
bool answer;
if(disks == 1)
...
}
// and used like
int main()
{
Disks obj(3);
bool b = ToH::test(obj.disks);
...
}