I cant find where to put friend when describing the class

http://puu.sh/8KePg.png

I keep trying to find where to put 'friend' when I want to define the class outside in this format in the screenshot i included... I keep getting an error wherever i put it... I cant find information on this please help.
I know if I want to include the defnition inside its like this
friend int F(PIP d) {//something}
closed account (j3Rz8vqX)
http://www.learncpp.com/cpp-tutorial/813-friend-functions-and-classes/

Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class myClass{
private:
    int data;
public:
    myClass(int i){data=i;}
    friend int myFunction(myClass data);
};
int myFunction(myClass mc)
{
    cout<<"The data was: "<<mc.data<<endl;
    return mc.data*2;
}
int main()
{
    myClass A(7);
    cout<<"Twice the data was: "<<myFunction(A)<<endl;
    return 0;
}
Last edited on
Topic archived. No new replies allowed.