Question

Write a C++ program to create a Book class. Define constructor and destructor for this class. Also define the methods to show the title and price of the books.

31 Jul 2018
Answer :
Word Count : 331

```cpp
#include <iostream>
#include <string>
using namespace std;

class Book {
private:
    string title;
    float price;

public:
    // Constructor to initialize title and price
    Book(string t, float p) {
        title = t;
        price = p;
        cout << "Book object created: " << title << " costing " << price << endl;
    }

______ ______ _______ ___ _______.
___ ________ _____ _____ __________ _____.
___ _________ ________ _____ _______ ________ ____ ___ _____ _____ ____ __________.
____ ___ _________ ___ __________ _________ ____ ______ __________ _______.
____ __________ ________ ________ ______ __________ __________.
_____ ______ ____ _______ ______.
_________ _______ _________ _________ ______ ______ __________ __________ ______ ______.
___ _______ ___ __________ _______ ____ _______ ______.
_______ ______ _____ _______ ______ ______ _______.
__________ ______ __________ _____ _____ ___ ___ ______ ____ _____ _______ _______.
____ _______ ______ ______ __________ ________ ____ _____ __________ _________ ________.
________ _________ ___ __________ __________ _______ ________ _____ ___.
____ __________ _________ __________ ________ ____ ______ ____.
________ _____ _____ ______ _________ ________ ______ _________ ____ _______ _________.
___ ________ ________ _____ ________ ________ _____.
_________ _____ ________ _____ ______ ________ ______ _________ _______ ____.
__________ ____ _________ ___ __________ ___ _________ ________ _____.
_______ _________ ______ _________ __________ ____ ________ __________ __________ ________ _____.
_____ _____ _________ ________ ____ _________ __________ ________ _______ __________ ________ _______.
_________ _________ ___ ___ _______ ___.
_______ __________ _____ _____ _______ __________ __________ ________ _____ _________.
___ ________ ______ ______ _________.
_________ _______ __________ ______ ___ _______ ___ _______ _____ ________ ______ ___.
_______ ______ ____ ______ ____ ___ ____ ________ _____ ________.
___ ______ __________ ___ ___.
___ ______ __________ _____ ____ ____ _________ _____ ___.
__________ ______ ______ ______ _______ _______.
______ __________ __________ ____ ________ ____ _________ _________ ___ ___ ________ _______.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU BCS 31 2016 - Write a C++ program to create a Book class. Define constructor and des | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→