Constructor Function
Lesson 28Author : 🦒
Last Updated : November, 2017
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;
}