Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 536947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:52:30+00:00 2026-05-13T09:52:30+00:00

I understand the basics of inheritance but this one is confusing me. How would

  • 0

I understand the basics of inheritance but this one is confusing me. How would you go about saying:

  • An album object has one or more artist objects
  • An album object has one or more song objects

My current code only will only allow one song per object:

class Song extends Album{}
class Album extends Artist{}

I’m sure i’m overlooking something important. Any thoughts?

I’m doing this in PHP

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:52:31+00:00Added an answer on May 13, 2026 at 9:52 am

    An album has one or more artist objects. Inheritance would mean an album is an artist. What you need is (EDIT) aggregation:

    class Album
    {
      public $artists = array(); // Array of Artist instances
      public $songs   = array(); // Array of Song instances
    }
    

    Aggregation means every Artist and Song instance may belong to other Albums. With composition, an artist or song may belong to a single Album.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm guessing there's something really basic about C# inheritance that I don't understand. Would
I understand the basics of Rx. Where I'm struggling is how you would actually
I understand the basics of a message queue system, but I have no idea
Okay so i understand the basics of MAXDOP , but i want to understand
Still learning this stuff on WPF, themes, derivations, etc. I understand basics on the
I understand the basics of PHP's glob function, but I'm having a bit of
I understand the basic principles of inheritance in OOP, but I have a specific
I am reasonably new to WPF and MVVM but I understand the basics. The
Trying to understand Ocaml's mechanism for named parameters. I understand the basics, but the
I'm new to Java, but I understand the basics. I know that interfaces are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.