2011-05-14 19 views
4

另外,如何在UML圖中最好地格式化重載的運算符成員函數?應該用UML圖表示朋友函數嗎?

這裏是我的類:

class matrix 
{ 
    friend ostream& operator << (ostream&, const matrix&); 
    friend bool operator == (const matrix &, const matrix &); 
    friend matrix operator - (const matrix &, 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 &); 
}; 

這裏就是我有我的UML圖的迄今:

enter image description here

+0

只是一個建議的話,與StavrUML /的StarUML做你的UML圖,而不是使用文字處理軟件,它更容易:) http://sourceforge.net/ projects/stavruml/ – 2011-05-14 15:55:28

回答

2

通過配售的刻板印象<<friend>>在前面的操作UML類圖。 你將不得不做這種方式:

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

什麼是一個刻板印象的朋友的例子;意大利麪食愛好者? :) – fredoverflow 2011-05-14 16:19:56

+0

@FredOverflow:害怕我不明白你的意思..... – 2011-05-14 16:30:20

+1

我只是想搞笑,猜測它沒有工作;) – fredoverflow 2011-05-14 18:12:24