CS253: Software Development with C++

Spring 2018

Friends

See this page as a slide show

CS253 Friends

Friend Declarations

One class can declare another class/method/function to be its friend:

class Foo {
    friend class Bar;                   // an entire class
    friend double Zip::zulu(int) const; // just one method
    friend int alpha();                 // a free function
    friend std::ostream &operator<<(std::ostream &os, const Foo &);
  private:
    int x,y;
};

Restrictions

Don’t go nuts

User: Guest

Check: HTML CSS
Edit History Source

Modified: 2018-04-24T16:51

Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2018 Colorado State University
CS Building