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 8441155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:29:31+00:00 2026-06-10T08:29:31+00:00

Here is my code: class LibItem { public: virtual void PrintDetails() = 0; virtual

  • 0

Here is my code:

class LibItem
{
public:
    virtual void PrintDetails() = 0;
    virtual void setDetails() = 0;
    void setTitle(string TitleName)
    {
        Title = TitleName;
    }
    string getTitle()
    {
        return Title;
    }
    void setReleaseDate(string date)
    {
        ReleaseDate = date;
    }
    string getReleaseDate()
    {
        return ReleaseDate;
    }
    void setAuthor(string AuthorName)
    {
        Author = AuthorName;
    }
    string getAuthor()
    {
        return Author;
    }
    void setCopyright(string CopyrightDetails)
    {
        Copyright = CopyrightDetails;
    }
    string getCopyright()
    {
        return Copyright;
    }
    void setGenre(string GenreDetails)
    {
        Genre = GenreDetails;
    }
    string getGenre()
    {
        return Genre;
    }
    void setStatus(string StatusDetails)
    {
        Status = StatusDetails;
    }
    string getStatus()
    {
        return Status;
    }
private:
    string Title;
    string ReleaseDate;
    string Author;
    string Copyright;
    string Genre;
    string Status;
};

class Book : public LibItem
{
public:
    Book(string TitleName)
    {
        setTitle(TitleName);
    }
    void setISBN(int ISBNDetails)
    {
        ISBN = ISBNDetails;
    }
    int getISBN()
    {
        return ISBN;
    }
    void setDetails(string setBookTitle, string setBookAuthor, string setBookReleaseDate, string setBookCopyright, string setBookGenre, string setBookStatus, int setBookISBN)
    {
        setTitle(setBookTitle);
        setAuthor(setBookAuthor);
        setReleaseDate(setBookReleaseDate);
        setCopyright(setBookCopyright);
        setGenre(setBookGenre);
        setStatus(setBookStatus);
        setISBN(setBookISBN);
    }
    void PrintDetails()
    {
        cout << "Title: " << getTitle() << endl;
        cout << "Author: " << getAuthor() << endl;
        cout << "Release Date: " << getReleaseDate() << endl;
        cout << "Copyrite: " << getCopyright() << endl;
        cout << "Genre: " << getGenre() << endl;
        cout << "Status: " << getStatus() << endl;
        cout << "ISBN: " << getISBN() << endl;
    }

private:
    Book();
    int ISBN;

};

class DVD : public LibItem
{
public:
    DVD(string TitleName)
    {
        setTitle(TitleName);
    }
    void setRunningTime(int RunningTimeDetails)
    {
        RunningTime = RunningTimeDetails;
    }
    int getRunningTime()
    {
        return RunningTime;
    }
    void setDirector(string DirectorDetails)
    {
        Director = DirectorDetails;
    }
    string getDirector()
    {
        return Director;
    }
    void setStudio(string StudioDetails)
    {
        Studio = StudioDetails;
    }
    string getStudio()
    {
        return Studio;
    }
    void setProducer(string ProducerDetails)
    {
        Producer = ProducerDetails;
    }
    string getProducer()
    {
        return Producer;
    }
    void setDetails(string setDVDTitle, string setDVDAuthor, string setDVDReleaseDate, string setDVDCopyright, string setDVDGenre, string setDVDStatus, int setDVDRunningTime, string setDVDDirector, string setDVDStudio, string setDVDProducer)
    {
        setTitle(setDVDTitle);
        setAuthor(setDVDAuthor);
        setReleaseDate(setDVDReleaseDate);
        setCopyright(setDVDCopyright);
        setGenre(setDVDGenre);
        setStatus(setDVDStatus);
        setDirector(setDVDDirector);
        setStudio(setDVDStudio);
        setProducer(setDVDProducer);
    }
    void PrintDetails()
    {
        cout << "Title: " << getTitle() << endl;
        cout << "Author: " << getAuthor() << endl;
        cout << "Release Date: " << getReleaseDate() << endl;
        cout << "Copyrite: " << getCopyright() << endl;
        cout << "Genre: " << getGenre() << endl;
        cout << "Status: " << getStatus() << endl;
        cout << "Running Time: " << getRunningTime() << endl;
        cout << "Director: " << getDirector() << endl;
        cout << "Studio: " << getStudio() << endl;
        cout << "Producer: " << getProducer() << endl;
    }

private:
    DVD();
    int RunningTime;
    string Director;
    string Studio;
    string Producer;

};

I am having trouble with the virtual void setDetails();

I am wanting both the Book and DVD class to have a method called setDetails to set the details. The problem is, both the Book class and the DVD class have different arguments for this method.

How can I achieve this?

How is the best way to solve this problem?

  • 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-06-10T08:29:32+00:00Added an answer on June 10, 2026 at 8:29 am

    Since

    setDetails(string setDVDTitle, string setDVDAuthor, string setDVDReleaseDate, string setDVDCopyright, string setDVDGenre, string setDVDStatus, int setDVDRunningTime, string setDVDDirector, string setDVDStudio, string setDVDProducer)
    

    only makes sense for a DVD object, and

    setDetails(string setBookTitle, string setBookAuthor, string setBookReleaseDate, string setBookCopyright, string setBookGenre, string setBookStatus, int setBookISBN)
    

    only makes sense for a Book, the methods shouldn’t be virtual, nor in the base class.

    Say I give you a LibItem* and I tell you to set its details. What do you do? Does it make sense to set its details, since they differ from one concrete implementing class to another?

    The base class should only have the method that sets:

    string Title;
    string ReleaseDate;
    string Author;
    string Copyright;
    string Genre;
    string Status;
    

    which shouldn’t be virtual, since its behavior doesn’t change from implementation to implementation, and you should set specific details on the implementing classes themselves.

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

Sidebar

Related Questions

Here is the code: class Test { public static void main (String[] args) throws
Here is the code: class Time { public static void printTime (int hour, int
Here is my code: class Soldier { public: Soldier(const string &name, const Gun &gun);
In the following code: public class A { public A():this(null){} public A(string b){/*code here*/}
Here my code snippet: class Request { public: Request(void); ……….. } Request::Request(void) { qDebug()<<Request:
Here is code example class A{ int i; public: A(int i) : i(i) {}
Here is the code: class Class1 { private Class2 object; public Class1(Class2 obj) :
Here's the code: class qual { public static int fibonacci(int n) { if (n
here's the code: class Acount { int sum ; String owner ; //these seem
Given the following code : public class Game { private Map<String,Coordinate> m_myHashMap; ... //

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.