您的位置:首页 > 其它

UML之十字圆圈连线箭头符号“包含”C…

2017-04-21 10:50 1251 查看
  在UML的类图里,这个一头带个十字圆圈(注意,不是带叉的圆圈)与连线组成的形式,表示内嵌。在实际编程代码中表示嵌在内部的类,通常用来表示突然在内部需要一个匿名类(如new
Thread()或者new Runnable()的情况)。
  英文介绍如下(摘自http://www.holub.com/goodies/uml/):Nesting,
Inner Class.[/b]. Identifies nesting (containment) relationships in
all diagrams. In a class diagram: an "inner" class whose definition
is nested within the "outer" class definition. Typically puts the
inner class in the name space of the outer class, but may have
additional properties.
  下面举个例子:




本图所对应的Java代码为:

public class SimpleClass
{

       
private Integer num = 3;

       
private Boolean isGood;

       
public Boolean isGoodEnough(Integer goodrange) {

           
return null;

       
}

       
public Integer getNum() {

           
return null;

       
}

       
public class InnerClass {

           
private Integer coolNum;

           
public Integer getCoolNum() {

               
return null;

           
}

       
}

   
}
对应的C++代码:

 
#ifndef SIMPLECLASS_H_H

#define SIMPLECLASS_H_H

class SimpleClass{

public:

            
class InnerClass{

            
public:

                         
Integer getCoolNum( );

            
private:

                         
Integer coolNum;

            
};

            
Integer getNum( );

            
Boolean isGoodEnough( Integer goodrange );

private:

            
Boolean isGood;

            
Integer num;

};

#endif
 
 

#include "SimpleClass.h"

Integer
SimpleClass::InnerClass::getCoolNum( ){

}

Boolean SimpleClass::isGoodEnough( Integer goodrange ){

}

Integer SimpleClass::getNum(
){

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: