如果A类包含B类对象的数组,那么正确的UML关系A取决于B吗?

时间:2018-03-08 12:43:41

标签: c++ uml

A类,注册类包含B类对象的私有数组,即Course类。

这是否意味着注册类取决于课程类,因为A类使用B类?或者更确切地说,它是一种聚合关系,因为A类有一个B类?

class Registration {
public:
  Registration();

  unsigned GetCredits() const;
  unsigned GetCount() const;

  friend ostream & operator <<( ostream & os, const Registration & R);

  friend istream & operator >>( istream & input, Registration & R );

private:
  long studentId;             // student ID number
  unsigned semester;          // semester year, number
  unsigned count;             // number of courses
  Course courses[MaxCourses]; // array of courses
};

class Course {
public:
  Course();
  Course( const char * nam, char sect, unsigned cred );

  unsigned GetCredits() const;

  void SetCredits( unsigned cred );

  friend ostream & operator <<( ostream & os, const Course & C );
  friend istream & operator >>( istream & input, Course & C );

private:
  char name[CourseNameSize];  // course name, C style string. not a C++ string object
  char section;   // section (letter) can be enrolment mode
  int  credits;   // number of credits
};

1 个答案:

答案 0 :(得分:0)

这是一个简单的联想:

enter image description here

点符号表示coursesRegistration的拥有属性。

不确定它是0..还是1..(可能是后者?)。