Thread: c++ program

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    9

    c++ program

    send me a simple program on friend functions

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Send us a simple program on friend functions, then we'll send it back to you with suggestions for improvement and relevant explanation of what you politely ask to be clarified.

    Read about the homework policy.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Send me $1,000,000.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  4. #4
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Quote Originally Posted by sve View Post
    send me a simple program on friend functions
    This is why I rarely post anymore.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  5. #5
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431
    Quote Originally Posted by sve View Post
    send me a simple program on friend functions
    Here you go:
    Code:
    #include <Friends>
    
    int main()
    {
        Chandler();
        Joey();
        Rachel();
        Ross();
        Phoebe();
        Monica();
        return 0;
    }
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  6. #6
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Here, I fleshed it out a bit:

    Code:
    #include <Friends>
    
    void Chandler() { std::cout << "Sarcastic guy" << std::endl; }
    void Joey() { std::cout << "Dumb guy" << std::endl; }
    void Rachel() { std::cout << "Frequently cold party girl" << std::endl; }
    void Ross() { std::cout << "Nerdy guy" << std::endl; }
    void Phoebe() { std::cout << "Earthy-crunchy chick" << std::endl; }
    void Monica() { std::cout << "OCD girl" << std::endl; }
    
    int main()
    {
        Chandler();
        Joey();
        Rachel();
        Ross();
        Phoebe();
        Monica();
        return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM