Constructor Function
Lesson 28Author : GOUP
Last Updated : September, 2020
Code
class Book{
public:
string title;
string author;
Book(string title, string author){
this->title = title;
this->author = author;
}
};
int main(){
Book book1("Harry Potter", "JK Rowling");
cout << book1.title << endl;
Book book2("Lord of the Rings", "JRR Tolkien");
cout << book2.title << endl;
return 0;
}