I want display assigned values to object creating by class. I use **strcpy_s ** to default constructor and overload constructor in book.cpp I implement overloading constructor using strcpy_s prevoius object assigned values are displaying. Object created using book class not displaying get erro message I attach error message screen shot below.
book.h
#pragma once
#include "visitor.h"
#include "RegisteredUser.h"
class Books {
private:
char bookId[10];
char isbn[10];
char title[30];
char author[20];
char publisher[20];
char publicationDate[15];
double price;
char language[10];
int noOfPages;
Visitor* booksVisitor;
RegisteredUser* user;
public:
Books();
Books(const char pbookId[], const char pisbn[], const char ptitle[], const char pauthor[], const char ppublisher[], const char ppublicationDate[], double pprice, const char planguage[], int pnoOfPages, RegisteredUser* puser, Visitor* pvisitor);
void displayBookDetails();
void storeBookDetails();
void maintainBookInventory();
~Books();
};
book.cpp
#include <iostream>
#include "book.h"
#include "RegisteredUser.h"
#include "visitor.h"
using namespace std;
Books::Books()
{
strcpy_s (bookId , "");
strcpy_s (isbn , "");
strcpy_s (title , "");
strcpy_s (author , "");
strcpy_s (publisher, "");
strcpy_s (publicationDate, "");
price = 0.00;
strcpy_s (language, "");
noOfPages = 0;
}
Books::Books(const char pbookId[], const char pisbn[], const char ptitle[], const char pauthor[], const char ppublisher[], const char ppublicationDate[], double pprice, const char planguage[], int pnoOfPages)
{
strcpy_s(bookId, pbookId);
strcpy_s(isbn, pisbn);
strcpy_s(title, ptitle);
strcpy_s(author, pauthor);
strcpy_s(publisher, ppublisher);
strcpy_s(publicationDate, ppublicationDate);
price = pprice;
strcpy_s(language, planguage);
noOfPages = pnoOfPages;
user = puser;
booksVisitor = pvisitor;
}
void Books::displayBookDetails() {
cout << "Book ID: " << bookId << endl;
cout << "ISBN: " << isbn << endl;
cout << "Title: " << title << endl;
cout << "Author: " << author << endl;
cout << "Publisher: " << publisher << endl;
cout << "Publication Date: " << publicationDate << endl;
cout << "Price: " << price << endl;
cout << "Language: " << language << endl;
cout << "Number of Pages: " << noOfPages << endl;
user->displayRegisteredUserDetails();
booksVisitor->display();
}
void Books::storeBookDetails() {
}
void Books::maintainBookInventory() {
}
Books::~Books()
{
}
main.cpp
// online-book-store.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include "visitor.h"
#include "RegisteredUser.h"
#include <cstring>
#include <string.h>
#include "book.h"
using namespace std;
int main()
{
Visitor* Vi1 = new Visitor("Mihi", "2001/01/01", "Male", "150/B Panadura", 719562217);
cout << "Visitor Details"<<endl;
Vi1->display();
RegisteredUser* r1 = new RegisteredUser("RU1234", "kavindu@gmail.com", "Kavindu01", "Mihi", "2001/01/01", "Male", "150/B Panadura", 719562217);
cout << "Registred User Details "<<endl;
r1->displayRegisteredUserDetails();
Books* B01 = new Books("B001", "1020B9GT", "Madol Duwa", "Martin Wickramasinghe","Galle Pubs","21/09/2004",2000.00,"Sinhala", 220,Vi1,r1);
B01->displayBookDetails();
}
@john updated book.h
#pragma once
#include "visitor.h"
#include "RegisteredUser.h"
class Books {
private:
string bookId;
string isbn;
string title;
string author;
string publisher;
string publicationDate;
float price;
string language;
int noOfPages;
Administrator* admin;
Visitor* visitor;
RegisteredUser* user;
public:
Books(string pbookId, string pisbn, string ptitle, string pauthor, string ppublisher, string ppublicationDate, float pprice, string planguage, int pnoOfPages,RegisteredUser* puser, Visitor* pvisitor);
void displayBookDetails();
void storeBookDetails();
void maintainBookInventory();
};
#include <iostream>
#include <iomanip>
#include <string>
#include <ostream>
#include "book.h"
#include "Admin.h"
#include "RegisteredUser.h"
#include "visitor.h"
using namespace std;
void Books::displayBookDetails() {
cout << "Book ID: " << bookId << endl;
cout << "ISBN: " << isbn << endl;
cout << "Title: " << title << endl;
cout << "Author: " << author << endl;
cout << "Publisher: " << publisher << endl;
cout << "Publication Date: " << publicationDate << endl;
cout << "Price: " << price << endl;
cout << "Language: " << language << endl;
cout << "Number of Pages: " << noOfPages << endl;
user->displayRegisteredUserDetails();
visitor->display();
admin->displayAdmin();
}
Books::Books(string pbookId, string pisbn, string ptitle, string pauthor, string ppublisher, string ppublicationDate, float pprice, string planguage, int pnoOfPages, Administrator* padmin, RegisteredUser* puser, Visitor* pvisitor) {
bookId = pbookId;
isbn = pisbn;
title = ptitle;
author = pauthor;
publisher = ppublisher;
publicationDate = ppublicationDate;
price = pprice;
language = planguage;
noOfPages = pnoOfPages;
user = puser;
admin = padmin;
visitor = pvisitor;
}
void Books::storeBookDetails() {
}
void Books::maintainBookInventory() {
}
I want to know the reason why is enter image description here error popin and solution for displaying object assigned values.