This repository has been archived on 2023-05-13. You can view files and clone it, but cannot push or open issues or pull requests.
mipt_cpp/seminar01_overload/05_add_price/add_price.cpp

21 lines
319 B
C++
Raw Normal View History

2022-09-05 18:29:46 +03:00
#include <iostream>
using std::cout, std::endl;
struct Book {
char title[100];
int pages;
float price;
};
void addPrice(Book& b, float x) {
b.price += x;
}
int main() {
Book b = {"One Hundred Years of Solitude", 456, 1200};
float x = 15.6;
addPrice(b, x);
cout << b.price << endl;
}