Hi mhb,
First thing I would do is start with some working code using the friend method. Then you can easily modify that to work with the member function method.
To get the friend method working, follow these steps:
Step 1:
Declare within your PhoneNumber class that the "ostream &operator<<(ostream &output, const PhoneNumber &num)" function is actually a friend. If you don't do that, the function will not have access to the private members.
Step 2:
You either need some way to initialize the PhoneNumber class or you need a member function to set the private fields (or both). I think it's good to have initialized classes, so I'd recommend adding a constructor to the class that takes an initial area code, exchange, and line and puts those values in its private members. Then, down in your main function you can use your new constructor to get some valid data in the instance of the class referenced by the "phone" variable.
Step 3:
Finish off that "int main()" function by adding a return statement and closing with a "}".
Hopefully you are familiar with how to carry out these three steps. If you have questions about them, definitely ask. Once you do this, you should actually be able to compile and run your app and see how it works. Then you'll want to change your friend function to a member function. The following are a list of things to consider while doing that:
1. You'll need to change the friend declaration within your PhoneNumber class to a public member function declaration, and where you define the "ostream &operator<<(ostream &output, const PhoneNumber &num)" function, you will need to add the "PhoneNumber" class name and scope resolution operator to indicate that it is a member of the PhoneNumber class.
2. You will need to consider the parameter list for the operator<< function. Now that it is a member of the PhoneNumber class, do you really need both of those parameters? (hint, hint)
3. In the main function, the "cout << phone << endl;" line will have to be modified. The " << endl;" part should still be fine, if you have done the member function correctly, but the "cout << phone" part will have to change to the two versions indicated in the assignment text that you included in your original post.
I hope this helps. I'm trying not to just give everything away - that won't help you get anything out of the assignment - so if you run into any problems, just post your questions.
-Ricci