I am new in C++ programming. I have exprience in python but c++ class is a bit confusing for me. I have search for this problem but can't seem to figure out the problem. Can any one help me?
#include <iostream>
using namespace std;
class Book
{
public:
string title, author;
Book(string t, string a)
{
title = t;
author = a;
}
void display()
{
cout << "Title: " << title << endl;
cout << "Author: " << author << endl;
}
};
class Card
{
public:
Book books[100];
int numberOfBooks = 0;
void store(Book book)
{
if (numberOfBooks < 100)
{
books[numberOfBooks] = book;
numberOfBooks++;
}
else
{
cout << "No more space" << endl;
}
}
void display()
{
for (int i = 0; i < numberOfBooks; i++)
{
books[i].display();
}
cout << "Number of books: " << numberOfBooks << endl;
}
};
int main()
{
Book b1 = Book("The Lord of the Rings", "J.R.R. Tolkien");
Book b2 = Book("Harry Potter", "J.K. Rowling");
Book b3 = Book("The Hunger Games", "Suzanne Collins");
Card c1 = Card(); // the default constructor of "Card" cannot be referenced -- it is a deleted function
c1.store(b1);
c1.store(b2);
c1.store(b3);
c1.display();
return 0;
}
So the problem is when i declare the class it's showing 'the default constructor of "Card" cannot be referenced -- it is a deleted function' this.