friend und non-member function

mathon

Grünschnabel
hallo,

ich sollte diese klasse implementieren:
Code:
namespace test_1
{
    class statistician
    {
    public:
        // CONSTRUCTOR
        statistician( );
        // MODIFICATION MEMBER FUNCTIONS
        void next(double r);
        void reset( );
        // CONSTANT MEMBER FUNCTIONS
        int length( ) const;
        double sum( ) const;
        double mean( ) const;
        double minimum( ) const;
        double maximum( ) const;
        // FRIEND FUNCTIONS
        friend statistician operator +
            (const statistician & s1, const statistician & s2);
        friend statistician operator *
            (double scale, const statistician & s);
    private:
        int count;       // How many numbers in the sequence
        double total;    // The sum of all the numbers in the sequence
        double tinyest;  // The smallest number in the sequence
        double largest;  // The largest number in the sequence
    };

    // NON-MEMBER functions for the statistician class
    bool operator ==(const statistician& s1, const statistician& s2);
}
Nur ist mir nicht ganz klar, was der unterschied der friend und non-member function (operator ==) zu den normalen member function in diesem header file ist bzw. wie ich diese im implmentation file dann definieren muss...? :confused:

kann mir hier jemand weiterhelfen?

lg matti
 
Zurück