R
Ramesh
Hello,
U could declare a class instead of the function and it can have data
members as that of the arguments u pass to the function u've
specified.And those data members are private while this function is
public .Its constructor will take those arguments which were taken by
your function.
Example:
class Recur{
private:
double a;
double b;
double res;
public :
Recur(double a1,double b1){
a=a1;b=b1;
}
double recur_func(){
Recur x1( a+b/2 , b+a/2 ),//Does something
x2( a*b/(a+b) , 2*a*b/(a+b) );
res = x1.recur_func() + x2.recur_func();
return res;
}
};
in main
main()
{
Recur s(21.0,51.0);
cout<<s.recur_func();
}
I think that'll do....
Bye..
U could declare a class instead of the function and it can have data
members as that of the arguments u pass to the function u've
specified.And those data members are private while this function is
public .Its constructor will take those arguments which were taken by
your function.
Example:
class Recur{
private:
double a;
double b;
double res;
public :
Recur(double a1,double b1){
a=a1;b=b1;
}
double recur_func(){
Recur x1( a+b/2 , b+a/2 ),//Does something
x2( a*b/(a+b) , 2*a*b/(a+b) );
res = x1.recur_func() + x2.recur_func();
return res;
}
};
in main
main()
{
Recur s(21.0,51.0);
cout<<s.recur_func();
}
I think that'll do....
Bye..