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/classroom_tasks/code/00namespace/03namespace_solution.cpp
2022-09-01 16:37:41 +03:00

36 lines
No EOL
811 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <cstdio>
namespace mipt
{
struct Book
{
char title[50];
int pages;
float price;
};
void printBook(Book b)
{
printf("%s, pages: %d, price: %.2f\n", b.title, b.pages, b.price);
}
}
int main()
{
mipt::Book b = {"War and Peace", 1200, 900};
mipt::printBook(b);
}
/*
Задание:
Структура Book и функция printBook определены в пространстве имён mipt
1) Создайте переменную типа структура Book и иницилизируйте
её значениями: "War and Peace", 1200, 900
2) Напечатайте созданную переменную с помощью функции printBook
*/