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

  • SEARCH
  • Home
  • 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 6932069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:39:33+00:00 2026-05-27T11:39:33+00:00

Simple question here. I have to define classes that will contain sets of books,

  • 0

Simple question here. I have to define classes that will contain sets of books, movies, CDs. I defined a template class, say Set<T>, with all the common methods, and then defined classes that derive from a particular instance (is it the correct term?) of the Set class

class Movies_set : public Set<Movie>
{
    /* ... */
}

in which I define some other methods (say a function to search for actors). Is it a good programming technique or are there more convenient methods?

  • 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-27T11:39:34+00:00Added an answer on May 27, 2026 at 11:39 am

    It depends on what Set actually is. I suspect Set is something similar to std::set and in that case, I would advice against derivation and steer you towards composition.

    The reason deriving from Set is a bad idea is because it exposes the API of set, which has nothing to do whatsoever with MovieSet. If you need methods to make searches to your MovieSet object, implement them on MovieSet itself, especially since, as you pointed out, you are going to augment MovieSet’s interface.

    This way, you would also gain something very powerful : encapsulation. If for some reason you decide to change from a Set to a std::map, the interface of your base class is likely to change and any code that accesses MovieSet will be impacted. If you had stored Set as a private data member, you would not run into this issue, as you would have already defined MovieSet’s appropriate accessors.

    That of course, if all based on my premise that Set is actually just a container.

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

Sidebar

Related Questions

I have a simple unit test case (extensive question here ) on a configuration
I have -- what I think -- is a simple question. Here's my code:
A little stuck here. I have a simple question I guess. Given the following
I'm trying to learn WPF, so here's a simple question, I hope: I have
I have a simple stupid question. Here's the problem, for years, my company has
this is probably too simple of a question, but here I go. I have
May it's very simple question, but I'm stuck here. I have variable val as
I have a simple question that I assume does not have a simple solution.
i found many related questions here. I have a simple java program . it
Simple question here: is there any way to convert from a jagged array to

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.