[ create a new paste ] login | about

Link: http://codepad.org/k04mdR5F    [ raw code | output | fork ]

C++, pasted on Jul 26:
# include <iostream>

void square(int&,int&);
void cube(int&,int&);
int main()
{
    int a=3;
    int b=4;


    void (*ptr) (int&,int&);


    ptr=cube;
    ptr(a,b);
    cout<<a<<endl<<b<<endl;

    a = 3; b = 4;

    ptr=square;
    ptr(a,b);
    cout<<a<<endl<<b<<endl;

    return 0;
}

void square (int &s,int &d)
{
    s*=s;
    d*=d;
}

void cube (int &s,int &d)
{
    int temp;
    temp=s;

    s*=s;
    s*=temp;
    temp=d;
    d*=d;
    d*=temp;
}


Output:
1
2
3
4
27
64
9
16


Create a new paste based on this one


Comments: