// TODO: Napisz przeładowania funkcji print dla struktury Book (przekazanie przez wartość, stałą wartość, referencję, stałą referencję, wskaźnik, wskaźnik do stałego obiektu)
struct Book {
string title;
int year;
};
void print(Book book) {
/*wypisuje Book przez wartość*/
cout << "Title: " << book.title << endl;
cout << "Year: " << book.year << endl;
}
//nie działa bo przecież to to samo co wyżej
void print(const Book book)
{
cout << "Title: " << book.title << endl;
cout << "Year: " << book.year << endl;
}
void print(Book &book) {
/*wypisuje Book przez referencję*/
cout << "Title: " << book.title << endl;
cout << "Year: " << book.year << endl;
}
void print(const Book &book) {
/*wypisuje Book przez stałą referencję*/
cout << "Title: " << book.title << endl;
cout << "Year: " << book.year << endl;
}
void print(Book *book) {
/*wypisuje Book przez wskaźnik*/
cout << "Title: " << book->title << endl;
cout << "Year: " << book->year << endl;
}
void print(const Book *book) {
/*wypisuje Book przez stały wskaźnik*/
cout << "Title: " << book->title << endl;
cout << "Year: " << book->year << endl;
}