0

Class A, the registration class contains a private array of objects of class B, the Course class.

Does this mean the registration class depends on the course class, as class A uses class B? Or rather is it an aggregation relationship, as class A has a class 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 Answers1

0

It's a simple association:

enter image description here

The dot-notation shows that courses is an owned property of Registration.

Not sure whether it's 0.. or 1.. (probably the latter?).

qwerty_so
  • 35,448
  • 8
  • 62
  • 86