Something went wrong. Try again.
Java--'s containers projects.intra.42.fr/projects/cpp-module-09
Something went wrong. Try again.
773 B · 34 lines
C++
at main
1234567891011121314151617181920212223242526272829303132333435#include <BitcoinExchange.hpp>
BitcoinExchange::BitcoinExchange() : data() {}
BitcoinExchange::BitcoinExchange(const std::map<std::string, double>& data) : data(data) {}
BitcoinExchange::BitcoinExchange(const BitcoinExchange& other) : data(other.data) {}
BitcoinExchange& BitcoinExchange::operator=(const BitcoinExchange& other) { if (this == &other) return *this;
data = other.data;
return *this;}
double BitcoinExchange::getValue(const std::string& date) const { std::map<std::string, double>::const_iterator it = data.lower_bound(date);
if (it == data.end()) return data.rbegin()->second;
if (it->first == date) return it->second;
if (it == data.begin()) return it->second;
--it; return it->second;}
BitcoinExchange::~BitcoinExchange() {}