# Purpose of the function of one class within the function of another class

• How to transfer a function that returns some value from one class as a variable to a function defined in another class. For now, my code looks like,

``````float A::decay(){
B b;
float N;
const int HL=946;
const int G=126;
float T;
if(b.min()>0){
T=(float)(b.min()-G)/HL;
N=pow(2,-T);
}
return N;
}
int B::min(){
int min=dtim[0][0][0];
for(int i=0;i<N;i++){
for(int j=0; j<K; j++){
for(int q=0; q<L; q++){
if (dtime[i][j][q] < min)min = dtime[i][j][q];
}
}
}
return min;
}
``````

When attempting to challenge the function min() in decay(), min is always zero.

• You've got a problem in your calculations. `min`and not in the transfer of the function. Not really. transferCall.♪ You don't do anything supernatural... The code below is your simplified version. But what do you have? `dtim`We don't know that! Then, in you. `decay` Establishment `B` A default designer, right? Maybe that. `b` all elements `dtim` - zero?

It's another case, if you really need to transfer one class member's function to another. ♪ ♪

``````class B
{
public:
B(int x):x(x){}
void out()
{
cout &lt;&lt; "b = " &lt;&lt; x &lt;&lt; endl;
}

private:
int x;
};
class A
{
public:
void func(int x)
{
B b(x);
b.out();
}
};
int main(int argc, const char * argv[])
{
A a;
a.func(5);
}
``````

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2