#include <iostream>
#include <string>

using namespace std;

class phone_number {
string phone;
public:
    phone_number(const string& p) {
        // validate p...
        if (p.size() != 10) {
            // Do something violent :)
            cerr << "The phone number is incorrect." << endl;
        }
        phone = p;
    }
    friend ostream& operator<<(ostream &os, const phone_number& p);
};

ostream& operator<<(ostream &os, const phone_number& pn) {
    const string &p(pn.phone);
    os << "(" << p.substr(0, 3) << ")" << p.substr(3, 3) << "-" << p.substr(6);
    return os;
}


int main() {
    phone_number p = phone_number("6152784567");
    cout << p << endl;
    return 0;
}