开发者

should friend functions be represented in UML diagrams?

开发者 https://www.devze.com 2023-03-06 03:05 出处:网络
Also, how exactly are overloaded operator member functions best formatted in a UML diagram? Here is my class:

Also, how exactly are overloaded operator member functions best formatted in a UML diagram?

Here is my class:

class matrix
{
    friend ostream& operator << (ostream&, const matrix&);
    friend bool operator == (const matrix &, const matrix &);
    friend matrix operator - (const matrix 开发者_如何学C&, const matrix &);

    private:
    int size;
    int range;
    int array[10][10];

    public:
    matrix(int);
    matrix(int, int);
    bool operator != (const matrix &) const;
    matrix operator + (const matrix &) const;
    const matrix & operator = (const matrix &);
};

and here is what I have of my UML diagram so far:

should friend functions be represented in UML diagrams?


By placing the stereotype <<friend>> in front of the operation in the UML class diagram. You will have to do it this way:

<<friend>> ostream& operator << (ostream&, const matrix&)
<<friend>> bool operator == (const matrix &, const matrix &)
<<friend>> matrix operator - (const matrix &, const matrix &)
0

精彩评论

暂无评论...
验证码 换一张
取 消