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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:22:24+00:00 2026-06-10T22:22:24+00:00

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

  • 0

Here is my Class code:

class LibItem
{
public:
    virtual void PrintDetails() = 0;
    void setDetails(string setItemTitle, string setItemAuthor, string setItemReleaseDate, string setItemCopyright, string setItemGenre, string setItemStatus)
    {
        Title = setItemTitle;
        Author = setItemAuthor;
        ReleaseDate = setItemReleaseDate;
        Copyright = setItemCopyright;
        Genre = setItemGenre;
        Status = setItemStatus;
    }
    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;
};

I am wanting to place this into a .h file and a .cpp file.
Is the below code correct?

LibItem.cpp:

//---------------------------------------------------------------------------

#pragma hdrstop

#include "LibItem.h"

virtual void LibItem::PrintDetails() = 0;
void LibItem::setDetails(string setItemTitle, string setItemAuthor, string setItemReleaseDate, string setItemCopyright, string setItemGenre, string setItemStatus)
{
Title = setItemTitle;
Author = setItemAuthor;
ReleaseDate = setItemReleaseDate;
Copyright = setItemCopyright;
Genre = setItemGenre;
Status = setItemStatus;
}
void LibItem::setTitle(string TitleName)
{
Title = TitleName;
}
string LibItem::getTitle()
{
return Title;
}
void LibItem::setReleaseDate(string date)
{
ReleaseDate = date;
}
string LibItem::getReleaseDate()
{
return ReleaseDate;
}
void LibItem::setAuthor(string AuthorName)
{
Author = AuthorName;
}
string LibItem::getAuthor()
{
return Author;
}
void LibItem::setCopyright(string CopyrightDetails)
{
Copyright = CopyrightDetails;
}
string LibItem::getCopyright()
{
return Copyright;
}
void LibItem::setGenre(string GenreDetails)
{
Genre = GenreDetails;
}
string LibItem::getGenre()
{
return Genre;
}
void LibItem::setStatus(string StatusDetails)
{
Status = StatusDetails;
}
string LibItem::getStatus()
{
return Status;
}
};

//---------------------------------------------------------------------------
#pragma package(smart_init)

LibItem.h

//---------------------------------------------------------------------------

#ifndef LibItemH
#define LibItemH

class LibItem
{
public:
    virtual void PrintDetails();
    void setDetails(string, string, string, string, string, string);
    void setTitle(string);
    void setReleaseDate(string);
    string getReleaseDate();
    void setAuthor(string);
    string getAuthor();
    void setCopyright(string);
    string getCopyright();
    void setGenre(string);
    string getGenre();
    void setStatus(string);
    string getStatus();
private:
    string Title;
    string ReleaseDate;
    string Author;
    string Copyright;
    string Genre;
    string Status;
};


//---------------------------------------------------------------------------
#endif

Next, if I am wanting to use this .h and .cpp file in a main function, what is the code needed to be able to do this? What are the include statements needed?

  • 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-10T22:22:26+00:00Added an answer on June 10, 2026 at 10:22 pm

    Not correct:

    virtual void LibItem::PrintDetails() = 0;
    

    The =0 should be inside the class definition (in the header).

    To use the class, you need to #include "LibItem.h".

    Also, in the header:

    #include <string>
    

    and replace occurences of string with std::string.

    string parameters should be passed by reference:

    void setReleaseDate(const string& date)
    

    instead of

    void setReleaseDate(string date)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code: class LibItem { public: virtual void PrintDetails() = 0; virtual
EDIT Here is my new code: class LibItem { public: //LibItem(); //LibItem(string setItemTitle, string
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);
here is a class code : > [DataObjectAttribute] public class > Report { public
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
See this code here: class test { int n; int *j; public: test(int m)
I'm trying to write a mysql class... enter code here class ASQL { public

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.