Post your project for free and start receiving proposals from freelancers within minutes after publication!
Writing a small program in C++
We prepare material for the content of the article.We have a task for which a decision should be implemented:
Implement a Buyer class template, parametrized by the Product type, which serves as an identifier for each product.For the product type, it is promised to implement a copy designer (and the assignment operator), a destructor, comparison operators and std::hash.The Buyer class must implement the following public methods:
* size_t products() const - returns the number of registered types of goods (i.e.not the number of units sold,
* void sell(const Product & p, size_t amount), - which reflects the sales amount of goods p
* size_t rank(const Product& p) const, which returns the number of times when the most sold goods are numbered from 1 (if several goods are sold equally, you can sort them as you want)
* const Product& product(size_t rank) const is a reverse function to rank (i.e.until the exception occurs, always performs product(rank(p)) == p a rank(product(r)) == r)
* size_t sold(size_t r) const - the number of sold units of the most sold product
* size_t sold(size_t from, size_t to) const - similar to one-parametric version, but returns the amount of sold units for the interval from and to (including both sides; thus sold(r, r) == sold(r) a sold(1, products()) is the total number of sold units for all kinds of goods; the introduction to < from is considered invalid.* size_t first_same(size_t r) const a size_t last_same(size_t r) returns the smallest (respectively the largest) rank r', for which sold(r') == sold(r)
* If the arguments of appeal are unacceptable (i.e.rank exceeds the boundaries or unknown work in the rank method ), call the exception std::out_of_range.
Implement a Buyer class template, parametrized by the Product type, which serves as an identifier for each product.For the product type, it is promised to implement a copy designer (and the assignment operator), a destructor, comparison operators and std::hash.The Buyer class must implement the following public methods:
* size_t products() const - returns the number of registered types of goods (i.e.not the number of units sold,
* void sell(const Product & p, size_t amount), - which reflects the sales amount of goods p
* size_t rank(const Product& p) const, which returns the number of times when the most sold goods are numbered from 1 (if several goods are sold equally, you can sort them as you want)
* const Product& product(size_t rank) const is a reverse function to rank (i.e.until the exception occurs, always performs product(rank(p)) == p a rank(product(r)) == r)
* size_t sold(size_t r) const - the number of sold units of the most sold product
* size_t sold(size_t from, size_t to) const - similar to one-parametric version, but returns the amount of sold units for the interval from and to (including both sides; thus sold(r, r) == sold(r) a sold(1, products()) is the total number of sold units for all kinds of goods; the introduction to < from is considered invalid.* size_t first_same(size_t r) const a size_t last_same(size_t r) returns the smallest (respectively the largest) rank r', for which sold(r') == sold(r)
* If the arguments of appeal are unacceptable (i.e.rank exceeds the boundaries or unknown work in the rank method ), call the exception std::out_of_range.