Odpowiedź :
Odpowiedź:
#include<iostream>
#include<string>
class Car {
std::string model;
int productionDate;
std::string color;
int price;
public:
Car(const std::string &model, int productionDate, const std::string &color, int price) : model(model),
productionDate(
productionDate),
color(color),
price(price) {}
friend void printData(const Car &car);
};
void printData(const Car &car) {
std::cout << car.model << '\n'
<< car.productionDate << '\n'
<< car.color << '\n'
<< car.price << '\n';
}
int main() {
Car car1("Audi", 2020, "czerwony", 22000);
printData(car1);
return 0;
}
Wyjaśnienie: